cshuo commented on a change in pull request #1600: [CALCITE-3527] Enrich tests 
for sql hints.
URL: https://github.com/apache/calcite/pull/1600#discussion_r349036861
 
 

 ##########
 File path: 
core/src/test/java/org/apache/calcite/test/SqlHintsConverterTest.java
 ##########
 @@ -185,20 +197,46 @@ protected DiffRepository getDiffRepos() {
         hints);
   }
 
-  @Test public void testInvalidTableHints() {
+  @Test public void testTableHintsInMerge() throws Exception {
+    final String sql = "merge into emps\n"
+        + "/*+ %s */ e\n"
+        + "using tempemps as t\n"
+        + "on e.empno = t.empno\n"
+        + "when matched then update\n"
+        + "set name = t.name, deptno = t.deptno, salary = t.salary * .1\n"
+        + "when not matched then insert (name, dept, salary)\n"
+        + "values(t.name, 10, t.salary * .15)";
+    final String sql1 = HintTools.withHint(sql);
+
+    final SqlMerge sqlMerge = (SqlMerge) tester.parseQuery(sql1);
+    assert sqlMerge.getTargetTable() instanceof SqlTableRef;
+    final SqlTableRef tableRef = (SqlTableRef) sqlMerge.getTargetTable();
+    List<RelHint> hints = SqlUtil.getRelHint(HintTools.HINT_STRATEGY_TABLE,
+        (SqlNodeList) tableRef.getOperandList().get(1));
+    assertHintsEquals(
+        Arrays.asList(
+            HintTools.PROPS_HINT,
+            HintTools.IDX_HINT,
+            HintTools.JOIN_HINT),
+        hints);
+  }
+
+  @Test public void testInvalidTableHints1() {
     final String sql = "select\n"
         + "ename, job, sal, dept.name\n"
         + "from emp /*+ weird_hint(idx1, idx2) */\n"
         + "join dept /*+ properties(k1='v1', k2='v2') */\n"
         + "on emp.deptno = dept.deptno";
     sql(sql).fails("Hint: WEIRD_HINT should be registered in the 
HintStrategies.");
+  }
 
+  @Test public void testInvalidTableHints2() {
 
 Review comment:
   ok. 

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to