You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by ja...@apache.org on 2015/07/25 04:13:28 UTC
[1/2] incubator-calcite git commit: [CALCITE-803] Add MYSQL_ANSI
Lexing policy.
Repository: incubator-calcite
Updated Branches:
refs/heads/master 26a087745 -> 5cb95e644
[CALCITE-803] Add MYSQL_ANSI Lexing policy.
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/e0a42301
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/e0a42301
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/e0a42301
Branch: refs/heads/master
Commit: e0a42301e5556685945ecbe2be83f93f10a1869f
Parents: 26a0877
Author: Jacques Nadeau <ja...@apache.org>
Authored: Fri Jul 24 09:53:02 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Fri Jul 24 18:48:54 2015 -0700
----------------------------------------------------------------------
.../java/org/apache/calcite/config/Lex.java | 8 +++++
.../java/org/apache/calcite/test/JdbcTest.java | 34 ++++++++++++++++++++
2 files changed, 42 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/e0a42301/core/src/main/java/org/apache/calcite/config/Lex.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/calcite/config/Lex.java b/core/src/main/java/org/apache/calcite/config/Lex.java
index c492d1b..d5a50cb 100644
--- a/core/src/main/java/org/apache/calcite/config/Lex.java
+++ b/core/src/main/java/org/apache/calcite/config/Lex.java
@@ -36,6 +36,14 @@ public enum Lex {
* Back-ticks allow identifiers to contain non-alphanumeric characters. */
MYSQL(Quoting.BACK_TICK, Casing.UNCHANGED, Casing.UNCHANGED, false),
+ /** Lexical policy similar to MySQL with ANSI_QUOTES option enabled. (To be
+ * precise: MySQL on Windows; MySQL on Linux uses case-sensitive matching,
+ * like the Linux file system.) The case of identifiers is preserved whether
+ * or not they quoted; after which, identifiers are matched
+ * case-insensitively. Double quotes allow identifiers to contain
+ * non-alphanumeric characters. */
+ MYSQL_ANSI(Quoting.DOUBLE_QUOTE, Casing.UNCHANGED, Casing.UNCHANGED, false),
+
/** Lexical policy similar to Microsoft SQL Server.
* The case of identifiers is preserved whether or not they are quoted;
* after which, identifiers are matched case-insensitively.
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/e0a42301/core/src/test/java/org/apache/calcite/test/JdbcTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/calcite/test/JdbcTest.java b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
index f365ab2..e466f39 100644
--- a/core/src/test/java/org/apache/calcite/test/JdbcTest.java
+++ b/core/src/test/java/org/apache/calcite/test/JdbcTest.java
@@ -5909,6 +5909,40 @@ public class JdbcTest {
});
}
+ /** Tests metadata for the MySQL ANSI lexical scheme. */
+ @Test public void testLexMySQLANSI() throws Exception {
+ CalciteAssert.that()
+ .with(Lex.MYSQL_ANSI)
+ .doWithConnection(
+ new Function<CalciteConnection, Void>() {
+ public Void apply(CalciteConnection connection) {
+ try {
+ DatabaseMetaData metaData = connection.getMetaData();
+ assertThat(metaData.getIdentifierQuoteString(), equalTo("\""));
+ assertThat(metaData.supportsMixedCaseIdentifiers(),
+ equalTo(false));
+ assertThat(metaData.storesMixedCaseIdentifiers(),
+ equalTo(true));
+ assertThat(metaData.storesUpperCaseIdentifiers(),
+ equalTo(false));
+ assertThat(metaData.storesLowerCaseIdentifiers(),
+ equalTo(false));
+ assertThat(metaData.supportsMixedCaseQuotedIdentifiers(),
+ equalTo(false));
+ assertThat(metaData.storesMixedCaseQuotedIdentifiers(),
+ equalTo(true));
+ assertThat(metaData.storesUpperCaseIdentifiers(),
+ equalTo(false));
+ assertThat(metaData.storesLowerCaseQuotedIdentifiers(),
+ equalTo(false));
+ return null;
+ } catch (SQLException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ });
+ }
+
/** Tests metadata for different the "SQL_SERVER" lexical scheme. */
@Test public void testLexSqlServer() throws Exception {
CalciteAssert.that()
[2/2] incubator-calcite git commit: [CALCITE-805] Add support for
using an alternative grammar specification for left and right curly braces.
Additionally, add support for including addition token manager declarations.
Posted by ja...@apache.org.
[CALCITE-805] Add support for using an alternative grammar specification for left and right curly braces. Additionally, add support for including addition token manager declarations.
Project: http://git-wip-us.apache.org/repos/asf/incubator-calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-calcite/commit/5cb95e64
Tree: http://git-wip-us.apache.org/repos/asf/incubator-calcite/tree/5cb95e64
Diff: http://git-wip-us.apache.org/repos/asf/incubator-calcite/diff/5cb95e64
Branch: refs/heads/master
Commit: 5cb95e644f38da1a13d6def96eeec935b650289c
Parents: e0a4230
Author: Jacques Nadeau <ja...@apache.org>
Authored: Fri Jul 24 16:38:18 2015 -0700
Committer: Jacques Nadeau <ja...@apache.org>
Committed: Fri Jul 24 18:49:36 2015 -0700
----------------------------------------------------------------------
core/src/main/codegen/config.fmpp | 2 ++
core/src/main/codegen/templates/Parser.jj | 8 ++++++++
2 files changed, 10 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/5cb95e64/core/src/main/codegen/config.fmpp
----------------------------------------------------------------------
diff --git a/core/src/main/codegen/config.fmpp b/core/src/main/codegen/config.fmpp
index d480488..80276c4 100644
--- a/core/src/main/codegen/config.fmpp
+++ b/core/src/main/codegen/config.fmpp
@@ -74,6 +74,8 @@ data: {
]
includeCompoundIdentifier: true
+ includeBraces: true
+ includeAdditionalDeclarations: false
}
}
http://git-wip-us.apache.org/repos/asf/incubator-calcite/blob/5cb95e64/core/src/main/codegen/templates/Parser.jj
----------------------------------------------------------------------
diff --git a/core/src/main/codegen/templates/Parser.jj b/core/src/main/codegen/templates/Parser.jj
index 36f9e05..231c03d 100644
--- a/core/src/main/codegen/templates/Parser.jj
+++ b/core/src/main/codegen/templates/Parser.jj
@@ -5382,12 +5382,16 @@ String CommonNonReservedKeyWord() :
{
< LPAREN: "(">
| < RPAREN: ")">
+ <#if parser.includeBraces >
| < LBRACE_D: "{" (" ")* ["d","D"] >
| < LBRACE_T: "{" (" ")* ["t","T"] >
| < LBRACE_TS: "{" (" ")* ["t","T"] ["s","S"] >
| < LBRACE_FN: "{" (" ")* ["f","F"] ["n","N"] >
| < LBRACE: "{" >
| < RBRACE: "}" >
+ <#else>
+ <#include "/@includes/braces.ftl" />
+ </#if>
| < LBRACKET: "[" >
| < RBRACKET: "]" >
| < SEMICOLON: ";" >
@@ -5432,6 +5436,10 @@ TOKEN_MGR_DECLS : {
void popState() {
SwitchTo(lexicalStateStack.remove(lexicalStateStack.size() - 1));
}
+
+ <#if parser.includeAdditionalDeclarations>
+ <#include "/@includes/tokenManagerDeclarations.ftl" />
+ </#if>
}
/*