Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/4015#discussion_r27710198
--- Diff: sql/core/src/main/scala/org/apache/spark/sql/SQLContext.scala ---
@@ -43,6 +43,67 @@ import org.apache.spark.util.Utils
import org.apache.spark.{Partition, SparkContext}
/**
+ * Currently we support the default dialect named "sql", associated with
the class
+ * [[DefaultSQLDialect]]
+ *
+ * And we can also provide custom SQL Dialect, for example in Spark SQL
CLI:
+ * {{{
+ *-- switch to "hiveql" dialect
+ * spark-sql>SET spark.sql.dialect=hiveql;
+ * spark-sql>SELECT * FROM src LIMIT 1;
+ *
+ *-- switch to "sql" dialect
+ * spark-sql>SET spark.sql.dialect=sql;
+ * spark-sql>SELECT * FROM src LIMIT 1;
+ *
+ *-- register the new SQL dialect
+ * spark-sql> SET spark.sql.dialect=com.xxx.xxx.SQL99Dialect;
+ * spark-sql> SELECT * FROM src LIMIT 1;
+ *
+ *-- register the non-exist SQL dialect
+ * spark-sql> SET spark.sql.dialect=NotExistedClass;
+ * spark-sql> SELECT * FROM src LIMIT 1;
+ *
+ *-- Exception will be thrown and switch to dialect
+ *-- "sql" (for SQLContext) or
+ *-- "hiveql" (for HiveContext)
+ * }}}
+ */
+@AlphaComponent
+abstract class SQLDialect {
+ /**
+ * We assume the DDLParser has higher priority than any of the other SQL
Parsers,
+ * We need to parse the DDL string first, if we can not get any result,
then will
+ * resort to the dialect parser.
+ */
+ @transient
+ protected[sql] val ddlParser = new DDLParser(parse)
--- End diff --
Since this is going to be a semi-public interface, I'd rather we kept it
very simple `abstract class` (i.e. just have `def parse(sqlText: String):
LogicalPlan`) and leave the handling of the ddlParser and everything else to
the context. We should also clearly state that `LogicalPlan` itself is not a
public interface and thus this part of the code does not have binary
compatibility guarantees like the rest of spark.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]