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

Cannot execute SQL on Snowflake connection with error : java.lang.IllegalArgumentException: Multiple entries with same key: CLASSES=JdbcTable {CLASSES} and CLASSES=JdbcTable {CLASSES}

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.35.0
    • None
    • jdbc-adapter
    • None
    • Important

    Description

      Might be similar to : DRILL-7415

      I am connected to Snowflake datasource using calcite connection and I am trying to execute SQL using a statement.

      I have only single table in database.

       

      My code :

      public static boolean getSnowflakeConnection() throws SQLException {
          String modelPath = "/Users/A200118159/Documents/Code/TestSpringBoot 2/src/main/resources/models/snowflake_model.json"; //"/Users/A200118159/test/snowflake_model.json";
          Properties properties = new Properties();
          properties.setProperty("model", modelPath);
          properties.setProperty("caseSensitive", "false");
      
      // Create a Calcite connection
          Connection connection = DriverManager.getConnection("jdbc:calcite:", properties);
          CalciteConnection calciteConnection = connection.unwrap(CalciteConnection.class);
      
      
          Statement statement = calciteConnection.createStatement();
          ResultSet resultSet = statement.executeQuery("SELECT * FROM PRODUCTS");
      
          printTable(resultSet);
          calciteConnection.close();
          return true;
        } 

      Snowflake Model File:

      {
        "version": "1.0",
        "defaultSchema": "Snowflake",
        "schemas": [
          {
            "name": "Snowflake",
            "type": "custom",
            "factory": "org.apache.calcite.adapter.jdbc.JdbcSchema$Factory",
            "operand": {
              "jdbcUser": "argus",
              "jdbcPassword": "Argus123",
              "jdbcUrl": "jdbc:snowflake://er14275.ap-southeast-1.snowflakecomputing.com/?warehouse=COMPUTE_WH&db=ARGUS_DATA&schema=ARGUS_SCHEMA",
              "jdbcDriver": "net.snowflake.client.jdbc.SnowflakeDriver"
            }
          }
        ]
      } 

      But I am getting below error:

      java.lang.IllegalArgumentException: Multiple entries with same key: CLASSES=JdbcTable \{CLASSES} and CLASSES=JdbcTable \{CLASSES}
          at com.google.common.collect.ImmutableMap.checkNoConflict(ImmutableMap.java:136) ~[guava-19.0.jar:na]
          at com.google.common.collect.RegularImmutableMap.checkNoConflictInKeyBucket(RegularImmutableMap.java:98) ~[guava-19.0.jar:na]
          at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:84) ~[guava-19.0.jar:na]
          at com.google.common.collect.ImmutableMap$Builder.build(ImmutableMap.java:295) ~[guava-19.0.jar:na]
          at org.apache.calcite.adapter.jdbc.JdbcSchema.computeTables(JdbcSchema.java:305) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.adapter.jdbc.JdbcSchema.getTableMap(JdbcSchema.java:361) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.adapter.jdbc.JdbcSchema.getTableNames(JdbcSchema.java:489) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CachingCalciteSchema$2.build(CachingCalciteSchema.java:86) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CachingCalciteSchema$2.build(CachingCalciteSchema.java:83) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CachingCalciteSchema$AbstractCached.get(CachingCalciteSchema.java:318) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CachingCalciteSchema.getImplicitTable(CachingCalciteSchema.java:142) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CalciteSchema.getTable(CalciteSchema.java:295) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.EmptyScope.resolve_(EmptyScope.java:144) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.EmptyScope.resolveTable(EmptyScope.java:101) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.DelegatingScope.resolveTable(DelegatingScope.java:230) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:116) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:188) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1144) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1115) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3456) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:3435) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3792) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:61) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:88) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:1144) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:1115) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:282) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:1090) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:796) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:598) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:257) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:220) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:665) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:519) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:487) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:236) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:630) ~[calcite-core-1.35.0.jar:1.35.0]
          at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:677) ~[avatica-core-1.23.0.jar:1.23.0]
          at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:157) ~[avatica-core-1.23.0.jar:1.23.0]
          at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:228) ~[avatica-core-1.23.0.jar:1.23.0]
          at com.viwa.TestSpringBoot.service.ProductService.getSnowflakeConnection(ProductService.java:77) ~[classes/:na]
          at com.viwa.TestSpringBoot.controller.ProductController.connectSnowflake(ProductController.java:59) ~[classes/:na]
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_351]
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_351]
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_351]
          at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_351]
          at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.24.jar:5.3.24]
          at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1071) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:964) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:670) ~[tomcat-embed-core-9.0.70.jar:4.0.FR]
          at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883) ~[spring-webmvc-5.3.24.jar:5.3.24]
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:779) ~[tomcat-embed-core-9.0.70.jar:4.0.FR]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) ~[tomcat-embed-websocket-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100) ~[spring-web-5.3.24.jar:5.3.24]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93) ~[spring-web-5.3.24.jar:5.3.24]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201) ~[spring-web-5.3.24.jar:5.3.24]
          at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117) ~[spring-web-5.3.24.jar:5.3.24]
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:177) ~[tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:891) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1784) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.70.jar:9.0.70]
          at java.lang.Thread.run(Thread.java:750) [na:1.8.0_351]
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            vishal.wakchaure Vishal Wakchaure
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: