[GEARPUMP-217] Remove irrelevant files, Update README.md
Author: Buddhi Ayesha <buddhiayesha.13@cse.mrt.ac.lk>
Closes #219 from buddhiayesha2015/sql.
diff --git a/experiments/sql/README.md b/experiments/sql/README.md
index 9880dff..28b6d2c 100644
--- a/experiments/sql/README.md
+++ b/experiments/sql/README.md
@@ -1,8 +1,8 @@
# SQL Support
-This project is about building a SQL layer with Apache Calcite to help those who are unfamiliar with Scala/Java to use Gearpump.
+This project is about building a SQL layer with [Apache Calcite](https://calcite.apache.org/) to help those who are unfamiliar with Scala/Java to use [Apache Gearpump](http://gearpump.apache.org/).
## Build
-- Build [GearPump SQL](https://github.com/buddhiayesha2015/incubator-gearpump/tree/sql/experiments/sql)
+- Build [GearPump SQL](/experiments/sql)
-## Test
-- Run [SQL WordCount example](https://github.com/buddhiayesha2015/incubator-gearpump/blob/sql/experiments/sql/src/test/java/org/apache/gearpump/sql/example/SqlWordCountTest.java)
+## Example
+- Run [SQL WordCount example](/experiments/sql/src/test/java/org/apache/gearpump/sql/example/SqlWordCountTest.java)
\ No newline at end of file
diff --git a/experiments/sql/src/main/java/org/apache/gearpump/sql/SQLNode.java b/experiments/sql/src/main/java/org/apache/gearpump/sql/SQLNode.java
deleted file mode 100644
index 7fcc3a1..0000000
--- a/experiments/sql/src/main/java/org/apache/gearpump/sql/SQLNode.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.gearpump.sql;
-
-import org.apache.calcite.avatica.util.Casing;
-import org.apache.calcite.avatica.util.Quoting;
-import org.apache.calcite.sql.SqlCall;
-import org.apache.calcite.sql.SqlNode;
-import org.apache.calcite.sql.SqlNodeList;
-import org.apache.calcite.sql.fun.SqlCase;
-import org.apache.calcite.sql.parser.SqlParseException;
-import org.apache.calcite.sql.parser.SqlParser;
-import org.apache.calcite.sql.parser.impl.SqlParserImpl;
-import org.apache.calcite.sql.validate.SqlConformanceEnum;
-import org.apache.calcite.sql.validate.SqlValidator;
-import org.apache.calcite.sql.validate.SqlValidatorScope;
-import org.apache.calcite.util.Util;
-import org.junit.ComparisonFailure;
-
-import java.util.regex.Pattern;
-
-public class SQLNode {
-
- private static final Pattern LINE_BREAK_PATTERN = Pattern.compile("\r\n|\r|\n");
-
- private static final Pattern TAB_PATTERN = Pattern.compile("\t");
-
- private static final String LINE_BREAK = "\\\\n\"" + Util.LINE_SEPARATOR + " + \"";
-
- private static final ThreadLocal<boolean[]> LINUXIFY = new ThreadLocal<boolean[]>() {
- @Override
- protected boolean[] initialValue() {
- return new boolean[]{true};
- }
- };
-
-
- protected SqlParser getSqlParser(String sql) {
- return SqlParser.create(sql,
- SqlParser.configBuilder()
- .setParserFactory(SqlParserImpl.FACTORY)
- .setQuoting(Quoting.DOUBLE_QUOTE)
- .setUnquotedCasing(Casing.TO_UPPER)
- .setQuotedCasing(Casing.UNCHANGED)
- .setConformance(SqlConformanceEnum.DEFAULT)
- .build());
- }
-
- public static String toJavaString(String s) {
- s = Util.replace(s, "\"", "\\\"");
- s = LINE_BREAK_PATTERN.matcher(s).replaceAll(LINE_BREAK);
- s = TAB_PATTERN.matcher(s).replaceAll("\\\\t");
- s = "\"" + s + "\"";
- String spurious = "\n \\+ \"\"";
- if (s.endsWith(spurious)) {
- s = s.substring(0, s.length() - spurious.length());
- }
- return s;
- }
-
- public static void assertEqualsVerbose(String expected, String actual) {
- if (actual == null) {
- if (expected == null) {
- return;
- } else {
- String message = "Expected:\n" + expected + "\nActual: null";
- throw new ComparisonFailure(message, expected, null);
- }
- }
- if ((expected != null) && expected.equals(actual)) {
- return;
- }
- String s = toJavaString(actual);
- String message = "Expected:\n" + expected + "\nActual:\n" +
- actual + "\nActual java:\n" + s + '\n';
-
- throw new ComparisonFailure(message, expected, actual);
- }
-
- public void check(String sql, String expected) {
- final SqlNode sqlNode;
- try {
- sqlNode = getSqlParser(sql).parseStmt();
- } catch (SqlParseException e) {
- throw new RuntimeException("Error while parsing SQL: " + sql, e);
- }
-
- String actual = sqlNode.toSqlString(null, true).getSql();
- if (LINUXIFY.get()[0]) {
- actual = Util.toLinux(actual);
- }
- assertEqualsVerbose(expected, actual);
- }
-
- public void validateCall(SqlCall call, SqlValidator validator, SqlValidatorScope operandScope) {
- SqlCase sqlCase = (SqlCase) call;
- SqlNodeList whenOperands = sqlCase.getWhenOperands();
- SqlNodeList thenOperands = sqlCase.getThenOperands();
- SqlNode elseOperand = sqlCase.getElseOperand();
- for (SqlNode operand : whenOperands) {
- operand.validateExpr(validator, operandScope);
- }
- for (SqlNode operand : thenOperands) {
- operand.validateExpr(validator, operandScope);
- }
- if (elseOperand != null) {
- elseOperand.validateExpr(validator, operandScope);
- }
- }
-
-}
\ No newline at end of file
diff --git a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Connection.scala b/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Connection.scala
deleted file mode 100644
index ee55aa8..0000000
--- a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Connection.scala
+++ /dev/null
@@ -1,153 +0,0 @@
-package org.apache.gearpump.experiments.sql
-
-import java.lang.reflect.Type
-import java.sql.{Blob, CallableStatement, Clob, DatabaseMetaData, NClob, PreparedStatement, SQLException, SQLWarning, SQLXML, Savepoint, Statement, Struct}
-import java.util.Properties
-import java.util.concurrent.Executor
-import java.{sql, util}
-
-import org.apache.calcite.adapter.java.JavaTypeFactory
-import org.apache.calcite.config.CalciteConnectionConfig
-import org.apache.calcite.jdbc.CalciteConnection
-import org.apache.calcite.linq4j.tree.Expression
-import org.apache.calcite.linq4j.{Enumerator, Queryable}
-import org.apache.log4j.Logger
-
-class Connection extends CalciteConnection {
-
- import org.apache.calcite.schema.SchemaPlus
- import org.apache.calcite.tools.Frameworks
-
- private val logger = Logger.getLogger(classOf[Nothing])
- private val rootSchema = Frameworks.createRootSchema(true)
- private var schema = ""
-
- @throws[SQLException]
- override def setSchema(s: String): Unit = {
- schema = s
- }
-
- override def getSchema: String = schema
-
- override def getTypeFactory: JavaTypeFactory = ???
-
- override def getProperties: Properties = ???
-
- override def getRootSchema: SchemaPlus = rootSchema
-
- override def config(): CalciteConnectionConfig = ???
-
- override def commit(): Unit = ???
-
- override def getHoldability: Int = 0
-
- override def setCatalog(catalog: String): Unit = ???
-
- override def setHoldability(holdability: Int): Unit = ???
-
- override def prepareStatement(sql: String): PreparedStatement = ???
-
- override def prepareStatement(sql: String, resultSetType: Int, resultSetConcurrency: Int): PreparedStatement = ???
-
- override def prepareStatement(sql: String, resultSetType: Int, resultSetConcurrency: Int, resultSetHoldability: Int): PreparedStatement = ???
-
- override def prepareStatement(sql: String, autoGeneratedKeys: Int): PreparedStatement = ???
-
- override def prepareStatement(sql: String, columnIndexes: Array[Int]): PreparedStatement = ???
-
- override def prepareStatement(sql: String, columnNames: Array[String]): PreparedStatement = ???
-
- override def createClob(): Clob = ???
-
- override def setClientInfo(name: String, value: String): Unit = ???
-
- override def setClientInfo(properties: Properties): Unit = ???
-
- override def createSQLXML(): SQLXML = ???
-
- override def getCatalog: String = ???
-
- override def createBlob(): Blob = ???
-
- override def createStatement(): Statement = ???
-
- override def createStatement(resultSetType: Int, resultSetConcurrency: Int): Statement = ???
-
- override def createStatement(resultSetType: Int, resultSetConcurrency: Int, resultSetHoldability: Int): Statement = ???
-
- override def abort(executor: Executor): Unit = ???
-
- override def setAutoCommit(autoCommit: Boolean): Unit = ???
-
- override def getMetaData: DatabaseMetaData = ???
-
- override def setReadOnly(readOnly: Boolean): Unit = ???
-
- override def prepareCall(sql: String): CallableStatement = ???
-
- override def prepareCall(sql: String, resultSetType: Int, resultSetConcurrency: Int): CallableStatement = ???
-
- override def prepareCall(sql: String, resultSetType: Int, resultSetConcurrency: Int, resultSetHoldability: Int): CallableStatement = ???
-
- override def setTransactionIsolation(level: Int): Unit = ???
-
- override def getWarnings: SQLWarning = ???
-
- override def releaseSavepoint(savepoint: Savepoint): Unit = ???
-
- override def nativeSQL(sql: String): String = ???
-
- override def isReadOnly: Boolean = ???
-
- override def createArrayOf(typeName: String, elements: Array[AnyRef]): sql.Array = ???
-
- override def setSavepoint(): Savepoint = ???
-
- override def setSavepoint(name: String): Savepoint = ???
-
- override def close(): Unit = ???
-
- override def createNClob(): NClob = ???
-
- override def rollback(): Unit = ???
-
- override def rollback(savepoint: Savepoint): Unit = ???
-
- override def setNetworkTimeout(executor: Executor, milliseconds: Int): Unit = ???
-
- override def setTypeMap(map: util.Map[String, Class[_]]): Unit = ???
-
- override def isValid(timeout: Int): Boolean = ???
-
- override def getAutoCommit: Boolean = ???
-
- override def clearWarnings(): Unit = ???
-
- override def getNetworkTimeout: Int = 0
-
- override def isClosed: Boolean = ???
-
- override def getTransactionIsolation: Int = 0
-
- override def createStruct(typeName: String, attributes: Array[AnyRef]): Struct = ???
-
- override def getClientInfo(name: String): String = ???
-
- override def getClientInfo: Properties = ???
-
- override def getTypeMap: util.Map[String, Class[_]] = ???
-
- override def unwrap[T](iface: Class[T]): T = ???
-
- override def isWrapperFor(iface: Class[_]): Boolean = ???
-
- override def execute[T](expression: Expression, aClass: Class[T]): T = ???
-
- override def execute[T](expression: Expression, `type`: Type): T = ???
-
- override def executeQuery[T](queryable: Queryable[T]): Enumerator[T] = ???
-
- override def createQuery[T](expression: Expression, aClass: Class[T]): Queryable[T] = ???
-
- override def createQuery[T](expression: Expression, `type`: Type): Queryable[T] = ???
-}
diff --git a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Query.scala b/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Query.scala
deleted file mode 100644
index 3ea0cec..0000000
--- a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/Query.scala
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.gearpump.experiments.sql
-
-import java.util
-
-import org.apache.calcite.config.Lex
-import org.apache.calcite.plan.{Contexts, ConventionTraitDef, RelTrait, RelTraitDef}
-import org.apache.calcite.rel.`type`.RelDataTypeSystem
-import org.apache.calcite.rel.{RelCollationTraitDef, RelNode}
-import org.apache.calcite.sql.parser.SqlParser
-import org.apache.calcite.tools._
-
-object Query {
-
- def getLogicalPlan(query: String): RelNode = {
-
- val traitDefs: util.List[RelTraitDef[_ <: RelTrait]] = new util.ArrayList[RelTraitDef[_ <: RelTrait]]
-
- traitDefs.add(ConventionTraitDef.INSTANCE)
- traitDefs.add(RelCollationTraitDef.INSTANCE)
-
- val config = Frameworks.newConfigBuilder()
- .parserConfig(SqlParser.configBuilder.setLex(Lex.MYSQL).build)
- .traitDefs(traitDefs)
- .context(Contexts.EMPTY_CONTEXT)
- .ruleSets(RuleSets.ofList())
- .costFactory(null)
- .typeSystem(RelDataTypeSystem.DEFAULT)
- .build();
-
- val queryPlanner = Frameworks.getPlanner(config)
- val sqlNode = queryPlanner.parse(query)
- val validatedSqlNode = queryPlanner.validate(sqlNode)
-
- queryPlanner.rel(validatedSqlNode).project()
- }
-
-}
diff --git a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/model/Model.scala b/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/model/Model.scala
deleted file mode 100644
index d8a0ad6..0000000
--- a/experiments/sql/src/main/scala/org/apache/gearpump/experiments/sql/model/Model.scala
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.gearpump.experiments.sql.model
-
-class Model {
-
- object QueryStatus extends Enumeration {
- type QueryStatus = Value
- val ACCEPTED, RUNNING, FAILED, COMPLETED = Value
- }
-
- var status = null
- var id = null
- var version = null
- var whenCreated = null
- var whenUpdated = null
-
-
-}