Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-6471

Improve performance of SqlToRelConverter by preventing unconditional conversion of sqlNodes to string for null-check messages

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.37.0
    • 1.38.0
    • core

    Description

      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:

              SqlNode elseOperand =
                  requireNonNull(caseNode.getElseOperand(),
                      "getElseOperand for " + caseNode);
      
        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);
        }
      
                return Pair.of(c, (e, fieldName) -> {
                  final int j = requireNonNull(fieldMap.get(fieldName), "field " + fieldName);
                  return rexBuilder.makeFieldAccess(e, j);
                });
      

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

      Attachments

        Issue Links

          Activity

            People

              korlov Konstantin Orlov
              korlov Konstantin Orlov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: