Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-19106

Sql. Column namings are partially broken after upgrading to calcite 1.34

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 3.0.0-beta1
    • None
    • sql

    Description

      After upgrading to calcite 1.34 SqlValidator#deriveAlias and overloading call IgniteSqlValidator#deriveAlias is changed, thus requests like :
      select v / 2 from t, return EXPR$ instead of column name derived from IgniteSqlValidator#deriveAlias. Fast (near) fix looks like cover both such queries:

      Check annotation for: SqlValidatorImpl#deriveAlias

      IgnitePlanner#validateAndGetTypeMetadata ->

          public ValidationResult validateAndGetTypeMetadata(SqlNode sqlNode) {
              SqlNode validatedNode = validator().validate(sqlNode);
              RelDataType type = validator().getValidatedNodeType(validatedNode);
              List<List<String>> origins = validator().getFieldOrigins(validatedNode);
      
              List<String> derived = Collections.emptyList();
      
              if (sqlNode instanceof SqlSelect) {
                  SelectScope list = validator().getRawSelectScope((SqlSelect) sqlNode);
                  assert type.getFieldList().size() == list.getExpandedSelectList().size();
      
                  int cnt = 0;
                  derived = new ArrayList<>(list.getExpandedSelectList().size());
                  for (SqlNode node : list.getExpandedSelectList()) {
                      derived.add(validator().deriveAlias(node, cnt++));
                  }
              }
      
              return new ValidationResult(validatedNode, type, origins, derived);
          }
      

      and use this derived instead of aliases here:
      PrepareServiceImpl#resultSetMetadata

      Be careful ! .net and cpp tests are involved too, check all issue number occurrences.

      Attachments

        Activity

          People

            zstan Evgeny Stanilovsky
            zstan Evgeny Stanilovsky
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 1h 10m
                1h 10m