c458edb77e
### What changes were proposed in this pull request? This PR proposes to support raw string literal which escape no character using `\`. The raw string literal is the form of `r"..."` or `r'...'` like the syntax BigQuery and Python supports. Actually, there is no standard way to represent raw string literals. In PostgreSQL, any special character isn't escaped by \ unless a string literal starts with E prefix. https://www.postgresql.org/docs/13/sql-syntax-lexical.html#SQL-SYNTAX-CONSTANTS In MySQL, special characters in a string literal are not escaped if NO_BACKSLASH_ESCAPES is enabled. https://dev.mysql.com/doc/refman/8.0/en/string-literals.html In MsSQLServer, any special character isn't escaped by \ but STRING_ESCAPE function can escape such characters. https://docs.microsoft.com/en-us/sql/t-sql/functions/string-escape-transact-sql?view=sql-server-ver15 But BigQuery supports `r"..."` and `r'...'` forms so this PR proposes this syntax for the purpose. https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#literals ### Why are the changes needed? In the current master, sometimes it's too confusable to represent JSON and regex in a string literal if they contain backslash. For example, in JSON, `\` needs to be escaped like as follows. ``` {"a": "\\"} ``` But, if the JSON above is represented in a string literal, further two `\` are needed because string literal also requires `\` to be escaped. ``` SELECT from_json('{"a": "\\\\"}', 'a string') {"a":"\"} ``` With the raw string literal, we can represent such JSON like as follows. ``` SELECT from_json(r'{"a": "\\"}', 'a string') {"a":"\"} ``` ### Does this PR introduce _any_ user-facing change? No. This PR just extends the existing syntax. ### How was this patch tested? Added new test. I also confirmed that the modified document is successfully built with `SKIP_API=1 bundle exec jekyll build`. ![raw_string_literal](https://user-images.githubusercontent.com/4736016/129223184-3bb4e206-f40f-42d2-a128-0cd8fc83b9c9.png) Closes #33599 from sarutak/raw-string-literal. Authored-by: Kousuke Saruta <sarutak@oss.nttdata.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> |
||
---|---|---|
.. | ||
catalyst | ||
core | ||
hive | ||
hive-thriftserver | ||
create-docs.sh | ||
gen-sql-api-docs.py | ||
gen-sql-config-docs.py | ||
gen-sql-functions-docs.py | ||
mkdocs.yml | ||
README.md |
Spark SQL
This module provides support for executing relational queries expressed in either SQL or the DataFrame/Dataset API.
Spark SQL is broken up into four subprojects:
- Catalyst (sql/catalyst) - An implementation-agnostic framework for manipulating trees of relational operators and expressions.
- Execution (sql/core) - A query planner / execution engine for translating Catalyst's logical query plans into Spark RDDs. This component also includes a new public interface, SQLContext, that allows users to execute SQL or LINQ statements against existing RDDs and Parquet files.
- Hive Support (sql/hive) - Includes extensions that allow users to write queries using a subset of HiveQL and access data from a Hive Metastore using Hive SerDes. There are also wrappers that allow users to run queries that include Hive UDFs, UDAFs, and UDTFs.
- HiveServer and CLI support (sql/hive-thriftserver) - Includes support for the SQL CLI (bin/spark-sql) and a HiveServer2 (for JDBC/ODBC) compatible server.
Running ./sql/create-docs.sh
generates SQL documentation for built-in functions under sql/site
, and SQL configuration documentation that gets included as part of configuration.md
in the main docs
directory.