Open AlexGruPerm opened 9 months ago
Need change query: Option[String] in ViewQueryMeta to class like this
case class optSqlQuery(query: Option[String], prefix: String = "$"){
def replaceParam(what: String, to: String): optSqlQuery =
optSqlQuery(query.map(s => s.replace(s"$prefix$what", s"$to")))
}
Than we can call replaceParam in insertFromQuery liek this
params.toList.sortBy(_.ord).foldLeft(strQuery) {
case (r, c) =>
c.chType match {
case "Decimal(38,6)" => r.replaceParam(c.name,mapCalcParams.getOrElse(c.name, "*****"))
case "String" => r.replaceParam(c.name,s"'${mapCalcParams.getOrElse(c.name, "*****")}'")
case "UInt32" => r.replaceParam(c.name,mapCalcParams.getOrElse(c.name, "*****"))
}
}
Example of SQL (calc) query
Name of parameters date_cache_1 datecalc_cache_1 curr_date_context analyt_datecalc
can be equal to field name or table name, etc.
It's better use parameter name with $, like $date_cache_1 $datecalc_cache_1 $curr_date_context $analyt_datecalc
Original query