calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bozo Dragojevic <bo...@digiverse.si>
Subject Re: SqlNode.toSqlString() not parseable by calcite?
Date Sat, 30 May 2020 16:39:16 GMT
On 28/05/2020 22:01, Julian Hyde wrote:
> Are you aware of SqlUnParserTest? It runs each query in SqlParserTest,
> converts the AST to SQL, and makes sure that that SQL can be parsed.
Julian,

Thank you for pointing me at the SqlUnParserTest!

If I'm reading the UnparsingTesterImpl.check() correctly it too
never actually tries to parse the expected result itself.

When I try adding that (see patch below) it works for most of the tests
and fails for testMatchRecognize* and testUnnest*.

What dialect are the expected results?

-----
$ git diff
diff --git a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
index 21b664fb4..6e459c6a7 100644
--- a/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
+++ b/core/src/test/java/org/apache/calcite/sql/parser/SqlParserTest.java
@@ -9060,6 +9060,12 @@ private void checkList(SqlNodeList sqlNodeList, List<String>
expected) {
       final String actual = sqlNode.toSqlString(transform).getSql();
       assertEquals(expected, linux(actual));

+      // Parse the expected result and unparse again.
+      SqlNode sqlNode42;
+      sqlNode42 = parseStmtAndHandleEx(expected, dialect2::configureParser, parser ->
{ });
+      final String sql42 = sqlNode42.toSqlString(transform).getSql();
+      assertEquals(expected, linux(sql42));
+
       // Unparse again in Calcite dialect (which we can parse), and
       // minimal parentheses.
       final String sql1 = sqlNode.toSqlString(simple()).getSql();

-----

Cheers,
Bozzo




> On Thu, May 28, 2020 at 2:14 AM Bozo Dragojevic <bozzo@digiverse.si> wrote:


Mime
View raw message