You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by GitBox <gi...@apache.org> on 2020/11/29 09:33:56 UTC

[GitHub] [kylin] zzcclp opened a new pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

zzcclp opened a new pull request #1490:
URL: https://github.com/apache/kylin/pull/1490


   ## Proposed changes
   
   Describe the big picture of your changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.
   
   ## Types of changes
   
   What types of changes does your code introduce to Kylin?
   _Put an `x` in the boxes that apply_
   
   - [ ] Bugfix (non-breaking change which fixes an issue)
   - [ ] New feature (non-breaking change which adds functionality)
   - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
   - [ ] Documentation Update (if none of the other choices apply)
   
   ## Checklist
   
   _Put an `x` in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code._
   
   - [ ] I have create an issue on [Kylin's jira](https://issues.apache.org/jira/browse/KYLIN), and have described the bug/feature there in detail
   - [ ] Commit messages in my PR start with the related jira ID, like "KYLIN-0000 Make Kylin project open-source"
   - [ ] Compiling and unit tests pass locally with my changes
   - [ ] I have added tests that prove my fix is effective or that my feature works
   - [ ] If this change need a document change, I will prepare another pr against the `document` branch
   - [ ] Any dependent changes have been merged
   
   ## Further comments
   
   If this is a relatively large or complex change, kick off the discussion at user@kylin or dev@kylin by explaining why you chose the solution you did and what alternatives you considered, etc...
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] codecov-io commented on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735369474


   # [Codecov](https://codecov.io/gh/apache/kylin/pull/1490?src=pr&el=h1) Report
   > :exclamation: No coverage uploaded for pull request base (`kylin-on-parquet-v2@51ff5ec`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
   > The diff coverage is `n/a`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/kylin/pull/1490/graphs/tree.svg?width=650&height=150&src=pr&token=JawVgbgsVo)](https://codecov.io/gh/apache/kylin/pull/1490?src=pr&el=tree)
   
   ```diff
   @@                  Coverage Diff                   @@
   ##             kylin-on-parquet-v2    #1490   +/-   ##
   ======================================================
     Coverage                       ?   24.08%           
     Complexity                     ?     4609           
   ======================================================
     Files                          ?     1136           
     Lines                          ?    64458           
     Branches                       ?     9511           
   ======================================================
     Hits                           ?    15524           
     Misses                         ?    47321           
     Partials                       ?     1613           
   ```
   
   
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/kylin/pull/1490?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/kylin/pull/1490?src=pr&el=footer). Last update [51ff5ec...3371191](https://codecov.io/gh/apache/kylin/pull/1490?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735626681


   From my side, there is some difference from old implementation, OLD impl will comare generated SQL with original one`Assert.assertEquals(expectedSQL, optimizedSQL);`. Please consider implement it later.  
   
   
   
   ```
       protected void execAndCompPlan(String queryFolder, String[] exclusiveQuerys, boolean needSort,
               ICompareQueryTranslator translator) throws Exception {
           logger.info("---------- test folder: " + new File(queryFolder).getAbsolutePath());
           Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys);
   
           List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql");
           for (File sqlFile : sqlFiles) {
               String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
               if (exclusiveSet.contains(queryName)) {
                   continue;
               }
               String sql1 = getTextFromFile(sqlFile);
               String sql2 = translator.transform(sqlFile);
   
               // execute Kylin
               logger.info("Query Result from Kylin - " + queryName + "  (" + queryFolder + ")");
               IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
               ITable kylinTable = executeQuery(kylinConn, queryName, sql1, needSort);
               RelNode calcitePlan = (RelNode) QueryContextFacade.current().getCalcitePlan();
               if (calcitePlan == null)
                   throw new NullPointerException();
   
               // execute H2
               logger.info("Query Result from H2 - " + queryName);
               long currentTime = System.currentTimeMillis();
               ITable h2Table = executeQuery(newH2Connection(), queryName, sql2, needSort);
               logger.info("H2 spent " + (System.currentTimeMillis() - currentTime) + " mili-seconds.");
   
               try {
                   // compare the result
                   assertTableEquals(h2Table, kylinTable);
               } catch (Throwable t) {
                   logger.info("execAndCompQuery failed on: " + sqlFile.getAbsolutePath());
                   throw t;
               }
   
               RelToSqlConverter converter = new RelToSqlConverter(CALCITE);
               SqlNode sqlNode = converter.visitChild(0, calcitePlan.getInput(0)).asStatement();
               String optimizedSQL = sqlNode.toSqlString(CALCITE).getSql();
               String expectedSQL = Strings.join(Files.readLines(
                       new File(sqlFile.getParent(), sqlFile.getName() + ".expected"), Charset.forName("utf-8")), "\n");
               Assert.assertEquals(expectedSQL, optimizedSQL);
               compQueryCount++;
               if (kylinTable.getRowCount() == 0) {
                   zeroResultQueries.add(sql1);
               }
           }
       }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zzcclp commented on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
zzcclp commented on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735648746


   > From my side, there is some difference from old implementation for `sql_plan`, OLD impl will comare generated SQL with original one`Assert.assertEquals(expectedSQL, optimizedSQL);`. Please consider implement it later.
   > 
   > ```
   >     protected void execAndCompPlan(String queryFolder, String[] exclusiveQuerys, boolean needSort,
   >             ICompareQueryTranslator translator) throws Exception {
   >         logger.info("---------- test folder: " + new File(queryFolder).getAbsolutePath());
   >         Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys);
   > 
   >         List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql");
   >         for (File sqlFile : sqlFiles) {
   >             String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
   >             if (exclusiveSet.contains(queryName)) {
   >                 continue;
   >             }
   >             String sql1 = getTextFromFile(sqlFile);
   >             String sql2 = translator.transform(sqlFile);
   > 
   >             // execute Kylin
   >             logger.info("Query Result from Kylin - " + queryName + "  (" + queryFolder + ")");
   >             IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
   >             ITable kylinTable = executeQuery(kylinConn, queryName, sql1, needSort);
   >             RelNode calcitePlan = (RelNode) QueryContextFacade.current().getCalcitePlan();
   >             if (calcitePlan == null)
   >                 throw new NullPointerException();
   > 
   >             // execute H2
   >             logger.info("Query Result from H2 - " + queryName);
   >             long currentTime = System.currentTimeMillis();
   >             ITable h2Table = executeQuery(newH2Connection(), queryName, sql2, needSort);
   >             logger.info("H2 spent " + (System.currentTimeMillis() - currentTime) + " mili-seconds.");
   > 
   >             try {
   >                 // compare the result
   >                 assertTableEquals(h2Table, kylinTable);
   >             } catch (Throwable t) {
   >                 logger.info("execAndCompQuery failed on: " + sqlFile.getAbsolutePath());
   >                 throw t;
   >             }
   > 
   >             RelToSqlConverter converter = new RelToSqlConverter(CALCITE);
   >             SqlNode sqlNode = converter.visitChild(0, calcitePlan.getInput(0)).asStatement();
   >             String optimizedSQL = sqlNode.toSqlString(CALCITE).getSql();
   >             String expectedSQL = Strings.join(Files.readLines(
   >                     new File(sqlFile.getParent(), sqlFile.getName() + ".expected"), Charset.forName("utf-8")), "\n");
   >             Assert.assertEquals(expectedSQL, optimizedSQL);
   >             compQueryCount++;
   >             if (kylinTable.getRowCount() == 0) {
   >                 zeroResultQueries.add(sql1);
   >             }
   >         }
   >     }
   > ```
   
   OK, we can support these test cases later.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus merged pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
hit-lacus merged pull request #1490:
URL: https://github.com/apache/kylin/pull/1490


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus commented on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
hit-lacus commented on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735637532


   For `sql_dynamic`, I think there are some difference
   
   ```java
       protected ITable executeDynamicQuery(IDatabaseConnection dbConn, String queryName, String sql,
               List<String> parameters, boolean needSort) throws Exception {
           QueryContextFacade.resetCurrent();
           QueryContextFacade.current().setProject(ProjectInstance.DEFAULT_PROJECT_NAME);
   
           // change join type to match current setting
           sql = changeJoinType(sql, joinType);
   
           PreparedStatement prepStat = dbConn.getConnection().prepareStatement(sql);
           for (int j = 1; j <= parameters.size(); ++j) {
               prepStat.setString(j, parameters.get(j - 1).trim());
           }
   
           ITable queryTable = dbConn.createTable(resultTableName + queryName, prepStat);
           String[] columnNames = new String[queryTable.getTableMetaData().getColumns().length];
           for (int i = 0; i < columnNames.length; i++) {
               columnNames[i] = queryTable.getTableMetaData().getColumns()[i].getColumnName();
           }
           if (needSort) {
               queryTable = new SortedTable(queryTable, columnNames);
           }
           if (PRINT_RESULT)
               printResult(queryTable);
           return queryTable;
       }
   ```
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] zzcclp commented on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
zzcclp commented on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735366703


   Ran test cases locally successfully.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [kylin] hit-lacus edited a comment on pull request #1490: KYLIN-4828 Add more sql test cases into NBuildAndQueryTest

Posted by GitBox <gi...@apache.org>.
hit-lacus edited a comment on pull request #1490:
URL: https://github.com/apache/kylin/pull/1490#issuecomment-735626681


   From my side, there is some difference from old implementation for `sql_plan`, OLD impl will comare generated SQL with original one`Assert.assertEquals(expectedSQL, optimizedSQL);`. Please consider implement it later.  
   
   
   
   ```
       protected void execAndCompPlan(String queryFolder, String[] exclusiveQuerys, boolean needSort,
               ICompareQueryTranslator translator) throws Exception {
           logger.info("---------- test folder: " + new File(queryFolder).getAbsolutePath());
           Set<String> exclusiveSet = buildExclusiveSet(exclusiveQuerys);
   
           List<File> sqlFiles = getFilesFromFolder(new File(queryFolder), ".sql");
           for (File sqlFile : sqlFiles) {
               String queryName = StringUtils.split(sqlFile.getName(), '.')[0];
               if (exclusiveSet.contains(queryName)) {
                   continue;
               }
               String sql1 = getTextFromFile(sqlFile);
               String sql2 = translator.transform(sqlFile);
   
               // execute Kylin
               logger.info("Query Result from Kylin - " + queryName + "  (" + queryFolder + ")");
               IDatabaseConnection kylinConn = new DatabaseConnection(cubeConnection);
               ITable kylinTable = executeQuery(kylinConn, queryName, sql1, needSort);
               RelNode calcitePlan = (RelNode) QueryContextFacade.current().getCalcitePlan();
               if (calcitePlan == null)
                   throw new NullPointerException();
   
               // execute H2
               logger.info("Query Result from H2 - " + queryName);
               long currentTime = System.currentTimeMillis();
               ITable h2Table = executeQuery(newH2Connection(), queryName, sql2, needSort);
               logger.info("H2 spent " + (System.currentTimeMillis() - currentTime) + " mili-seconds.");
   
               try {
                   // compare the result
                   assertTableEquals(h2Table, kylinTable);
               } catch (Throwable t) {
                   logger.info("execAndCompQuery failed on: " + sqlFile.getAbsolutePath());
                   throw t;
               }
   
               RelToSqlConverter converter = new RelToSqlConverter(CALCITE);
               SqlNode sqlNode = converter.visitChild(0, calcitePlan.getInput(0)).asStatement();
               String optimizedSQL = sqlNode.toSqlString(CALCITE).getSql();
               String expectedSQL = Strings.join(Files.readLines(
                       new File(sqlFile.getParent(), sqlFile.getName() + ".expected"), Charset.forName("utf-8")), "\n");
               Assert.assertEquals(expectedSQL, optimizedSQL);
               compQueryCount++;
               if (kylinTable.getRowCount() == 0) {
                   zeroResultQueries.add(sql1);
               }
           }
       }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org