[ 
https://issues.apache.org/jira/browse/IGNITE-25320?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Maksim Zhuravkov updated IGNITE-25320:
--------------------------------------
    Description: 
CAST FORMAT operation creates an instance of SqlFunctions.ParseFunction on for 
row it processes.

This function has an internal cache for each format it encounters but the cache 
is not used because each instance is created once per row and then it is thrown 
away.

{noformat}
public void project(org.apache.ignite.internal.sql.engine.exec.ExecutionContext 
ctx, Object row, 
org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder outBuilder) {
  try {
    final String value_dynamic_param = ctx.getParameter("?0", 
java.lang.String.class) == null ? null : ctx.getParameter("?0", 
java.lang.String.class).toString();
    outBuilder.addField(value_dynamic_param == null ? 0L : 
org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(new
 
org.apache.calcite.runtime.SqlFunctions.DateParseFunction().parseTimestamp("yyyy-MM-dd
 HH:mm:ss", value_dynamic_param))));
  } catch (Exception e) {
    throw new org.apache.ignite.sql.SqlException(
      262151,
      e);
  }
}

{noformat}

IgniteSqlFunctions.toTimestampWithLocalTimeZone creates an instance of that 
function as well.



  was:
CAST FORMAT operation creates an instance of SqlFunctions.ParseFunction on 
every call.

This function has an internal cache for each format it encounters but the cache 
is not used because each instance is created once per row and then it is thrown 
away.

{noformat}
public void project(org.apache.ignite.internal.sql.engine.exec.ExecutionContext 
ctx, Object row, 
org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder outBuilder) {
  try {
    final String value_dynamic_param = ctx.getParameter("?0", 
java.lang.String.class) == null ? null : ctx.getParameter("?0", 
java.lang.String.class).toString();
    outBuilder.addField(value_dynamic_param == null ? 0L : 
org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(new
 
org.apache.calcite.runtime.SqlFunctions.DateParseFunction().parseTimestamp("yyyy-MM-dd
 HH:mm:ss", value_dynamic_param))));
  } catch (Exception e) {
    throw new org.apache.ignite.sql.SqlException(
      262151,
      e);
  }
}

{noformat}

IgniteSqlFunctions.toTimestampWithLocalTimeZone creates an instance of that 
function as well.




> Sql. Cast FORMAT. Improve code generation in RexToLitTransator
> --------------------------------------------------------------
>
>                 Key: IGNITE-25320
>                 URL: https://issues.apache.org/jira/browse/IGNITE-25320
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql
>            Reporter: Maksim Zhuravkov
>            Priority: Major
>              Labels: ignite-3
>
> CAST FORMAT operation creates an instance of SqlFunctions.ParseFunction on 
> for row it processes.
> This function has an internal cache for each format it encounters but the 
> cache is not used because each instance is created once per row and then it 
> is thrown away.
> {noformat}
> public void 
> project(org.apache.ignite.internal.sql.engine.exec.ExecutionContext ctx, 
> Object row, org.apache.ignite.internal.sql.engine.exec.RowHandler.RowBuilder 
> outBuilder) {
>   try {
>     final String value_dynamic_param = ctx.getParameter("?0", 
> java.lang.String.class) == null ? null : ctx.getParameter("?0", 
> java.lang.String.class).toString();
>     outBuilder.addField(value_dynamic_param == null ? 0L : 
> org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(org.apache.ignite.internal.sql.engine.exec.exp.IgniteSqlFunctions.toTimestampExact(new
>  
> org.apache.calcite.runtime.SqlFunctions.DateParseFunction().parseTimestamp("yyyy-MM-dd
>  HH:mm:ss", value_dynamic_param))));
>   } catch (Exception e) {
>     throw new org.apache.ignite.sql.SqlException(
>       262151,
>       e);
>   }
> }
> {noformat}
> IgniteSqlFunctions.toTimestampWithLocalTimeZone creates an instance of that 
> function as well.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to