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

Elasticsearch adapter should support aliases

    XMLWordPrintableJSON

Details

    Description

      I have a index is 'ndcp_metrics_collector_status_202303' and the alias is 'ndcp_metrics_collector_status'

      {
          "ndcp_metrics_collector_status_202303":
          {
              "aliases":
              {
                  "ndcp_metrics_collector_status":
                  {}
              },
              "mappings":
              { 

      Query using index name is successful, but query using alias name fails

      Exception in thread "main" java.sql.SQLException: Error while executing SQL "SELECT * FROM es.ndcp_metrics_collector_status WHERE _MAP['header.type'] = 'HEARTBEAT' offset 0 fetch next 3 rows only": From line 1, column 15 to line 1, column 46: Object 'NDCP_METRICS_COLLECTOR_STATUS' not found within 'es'
          at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
          at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
          at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:164)
          at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:228)
          at com.coolbeevip.calcite.elasticsearch.Main.main(Main.java:48)
      Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to line 1, column 46: Object 'NDCP_METRICS_COLLECTOR_STATUS' not found within 'es'
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
          at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:945)
          at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:930)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5464)
          at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:138)
          at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:188)
          at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1135)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1106)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3429)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3408)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3766)
          at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:61)
          at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1135)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1106)
          at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:282)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1081)
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:787)
          at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:597)
          at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:257)
          at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:220)
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:665)
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:519)
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:487)
          at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:236)
          at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:621)
          at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:677)
          at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:157)
          ... 2 more
      Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Object 'NDCP_METRICS_COLLECTOR_STATUS' not found within 'es'
          at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
          at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
          at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
          at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
          at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:505)
          at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:599)
          ... 30 more 

      Attachments

        Issue Links

          Activity

            People

              zhanglei Lei Zhang
              zhanglei Lei Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 3h
                  3h