[ 
https://issues.apache.org/jira/browse/KYLIN-4828?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17240563#comment-17240563
 ] 

ASF GitHub Bot commented on KYLIN-4828:
---------------------------------------

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:
[email protected]


> Add more sql test cases into NBuildAndQueryTest
> -----------------------------------------------
>
>                 Key: KYLIN-4828
>                 URL: https://issues.apache.org/jira/browse/KYLIN-4828
>             Project: Kylin
>          Issue Type: Improvement
>          Components: Query Engine
>            Reporter: Zhichao  Zhang
>            Assignee: Zhichao  Zhang
>            Priority: Minor
>             Fix For: v4.0.0-beta
>
>
> Add more sql test cases into NBuildAndQueryTest



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to