Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-15799

Solr SQL should allow the schema name on table names if possible

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • Parallel SQL

    Description

      Started kicking the tires on Solr SQL with Superset and the first issue I encountered is Calcite's parsing doesn't like the schema name (Solr uses default) on table names, such as:

      Caused by: java.sql.SQLException: Error while executing SQL "SELECT genre_s AS genre_s,
             COUNT(*) AS `count`
      FROM `default`.books
      GROUP BY genre_s
      ORDER BY `count` DESC
      LIMIT 100": From line 3, column 6 to line 3, column 20: Object 'default' not found
      	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:163) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) ~[?:?]
      	at org.apache.solr.client.solrj.io.stream.JDBCStream.open(JDBCStream.java:283) ~[?:?]
      	... 55 more
      Caused by: org.apache.calcite.runtime.CalciteContextException: From line 3, column 6 to line 3, column 20: Object 'default' not found
      	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
      	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
      	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:506) ~[?:?]
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917) ~[?:?]
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:902) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5271) ~[?:?]
      	at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:183) ~[?:?]
      	at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:188) ~[?:?]
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1098) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1069) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3380) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3362) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3644) ~[?:?]
      	at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:64) ~[?:?]
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1098) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1069) ~[?:?]
      	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:247) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1044) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:750) ~[?:?]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:585) ~[?:?]
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:251) ~[?:?]
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:215) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:647) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:513) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:483) ~[?:?]
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:249) ~[?:?]
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:623) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) ~[?:?]
      	at org.apache.solr.client.solrj.io.stream.JDBCStream.open(JDBCStream.java:283) ~[?:?]
      	... 55 more
      Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Object 'default' not found
      	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
      	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:?]
      	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[?:?]
      	at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:506) ~[?:?]
      	at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:600) ~[?:?]
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:917) ~[?:?]
      	at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:902) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:5271) ~[?:?]
      	at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:183) ~[?:?]
      	at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:188) ~[?:?]
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1098) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1069) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3380) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3362) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3644) ~[?:?]
      	at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:64) ~[?:?]
      	at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:89) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1098) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1069) ~[?:?]
      	at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:247) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1044) ~[?:?]
      	at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:750) ~[?:?]
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:585) ~[?:?]
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:251) ~[?:?]
      	at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:215) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:647) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:513) ~[?:?]
      	at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:483) ~[?:?]
      	at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:249) ~[?:?]
      	at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:623) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156) ~[?:?]
      	at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227) ~[?:?]
      	at org.apache.solr.client.solrj.io.stream.JDBCStream.open(JDBCStream.java:283) ~[?:?]
      	... 55 more
      

      Seems like `default`.TABLE should work but not sure if this is a Calcite setting or something we're not doing correctly in the Solr code. See screenshot ... need to figure out where the default schema name is even coming from??

      Attachments

        1. Screen Shot 2021-11-15 at 2.07.24 PM.png
          180 kB
          Timothy Potter
        2. Screen Shot 2021-11-15 at 1.55.14 PM.png
          60 kB
          Timothy Potter

        Activity

          People

            thelabdude Timothy Potter
            thelabdude Timothy Potter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: