Konstantin Orlov created CALCITE-6471:
-----------------------------------------

             Summary: Prevent unconditional conversion of sqlNodes to string 
for null-check messages in SqlToRelConverter 
                 Key: CALCITE-6471
                 URL: https://issues.apache.org/jira/browse/CALCITE-6471
             Project: Calcite
          Issue Type: Improvement
          Components: core
    Affects Versions: 1.37.0
            Reporter: Konstantin Orlov


Currently, {{SqlToRelConverter}} contains a few places where {{sqlNode}} is 
concatenated to some prefix and passed as plain string rather that message 
supplier as parameter to {{requireNonNull}} method. These are, namely, lines 
1019, 4031, and 5344 at commit  29c413a3:

{code:java}
        SqlNode elseOperand =
            requireNonNull(caseNode.getElseOperand(),
                "getElseOperand for " + caseNode);
{code}

{code:java}
  protected RelOptTable getTargetTable(SqlNode call) {
    final SqlValidatorNamespace targetNs = getNamespace(call);
    SqlValidatorNamespace namespace;
    if (targetNs.isWrapperFor(SqlValidatorImpl.DmlNamespace.class)) {
      namespace = targetNs.unwrap(SqlValidatorImpl.DmlNamespace.class);
    } else {
      namespace = targetNs.resolve();
    }
    RelOptTable table = SqlValidatorUtil.getRelOptTable(namespace, 
catalogReader, null, null);
    return requireNonNull(table, "no table found for " + call);
  }
{code}

{code:java}
          return Pair.of(c, (e, fieldName) -> {
            final int j = requireNonNull(fieldMap.get(fieldName), "field " + 
fieldName);
            return rexBuilder.makeFieldAccess(e, j);
          });
{code}

We can shave a few microseconds by simply replacing plain string with message 
supplier.




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

Reply via email to