I9996 value limits it fails oracle (#10027)

* Creating OR predicate to reduce length of string literals
CHANGELOG_BEGIN
CHANGELOG_END

* removing unnecessary thrown exception
CHANGELOG_BEGIN
CHANGELOG_END

* switching to camel case for constants
CHANGELOG_BEGIN
CHANGELOG_END

* run format
CHANGELOG_BEGIN
CHANGELOG_END

* remove tolist conversion
CHANGELOG_BEGIN
CHANGELOG_END

* scalafmt

Co-authored-by: Brian Healey <brian.healey@digitalasset.com>
This commit is contained in:
danielporterda 2021-06-17 19:48:31 -04:00 committed by GitHub
parent febca5d62d
commit f3106c3e34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,8 +62,31 @@ private[dao] object SqlFunctions {
object OracleSqlFunctions extends SqlFunctions {
// TODO https://github.com/digital-asset/daml/issues/9493
// This is likely extremely inefficient due to the multiple full tablescans on unindexed varray column
override def arrayIntersectionWhereClause(arrayColumn: String, parties: Set[Party]): String =
s"""JSON_EXISTS($arrayColumn, '$$[*]?(@ in ("${parties.mkString("""", """")}"))')"""
override def arrayIntersectionWhereClause(arrayColumn: String, parties: Set[Party]): String = {
val NumCharsBetweenParties = 3
val NumExtraChars = 20
val OracleMaxStringLiteralLength = 4000
val groupedParties =
parties.foldLeft((List.empty[List[String]], 0))({ case ((prev, currentLength), party) =>
if (
currentLength + party.length + NumCharsBetweenParties > OracleMaxStringLiteralLength
) {
(List(party) :: prev, party.length + NumExtraChars)
} else {
prev match {
case h :: tail =>
((party :: h) :: tail, currentLength + party.length + NumCharsBetweenParties)
case Nil => (List(party) :: Nil, party.length + NumExtraChars)
}
}
})
"(" + groupedParties._1
.map { listOfParties =>
s"""JSON_EXISTS($arrayColumn, '$$[*]?(@ in ("${listOfParties.mkString("""","""")}"))')"""
}
.mkString(" OR ") + ")"
}
override def arrayIntersectionValues(arrayColumn: String, parties: Set[Party]): String =
s"""(select json_arrayagg(value) from (select value