-
Notifications
You must be signed in to change notification settings - Fork 29.1k
[SPARK-31502][SQL][DOCS] Document identifier in SQL Reference #28277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
3e16242
b0b1262
837a691
15f0402
21b6eb1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| --- | ||
| layout: global | ||
| title: Identifiers | ||
| displayTitle: Identifiers | ||
| license: | | ||
| 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. | ||
| --- | ||
|
|
||
| ### Description | ||
|
|
||
| An identifier is a string used to identify a database object such as a table, view, schema, column, etc. Spark SQL has regular identifiers and delimited identifiers, which are enclosed within backticks. Both regular identifiers and delimited identifiers are case-insensitive. | ||
|
|
||
| ### Syntax | ||
|
|
||
| #### Regular Identifier | ||
|
|
||
| {% highlight sql %} | ||
| { letter | digit | '_' } [ , ... ] | ||
| {% endhighlight %} | ||
| Note: If `spark.sql.ansi.enabled` is set to true, ANSI SQL reserved keywords cannot be used as identifiers. For more details, please refer to [ANSI Compliance](sql-ref-ansi-compliance.html). | ||
|
|
||
| #### Delimited Identifier | ||
|
|
||
| {% highlight sql %} | ||
| `c [ ... ]` | ||
| {% endhighlight %} | ||
|
|
||
| ### Parameters | ||
|
|
||
| <dl> | ||
| <dt><code><em>letter</em></code></dt> | ||
| <dd> | ||
| Any letter from A-Z or a-z. | ||
| </dd> | ||
| </dl> | ||
| <dl> | ||
| <dt><code><em>digit</em></code></dt> | ||
| <dd> | ||
| Any numeral from 0 to 9. | ||
| </dd> | ||
| </dl> | ||
| <dl> | ||
| <dt><code><em>c</em></code></dt> | ||
| <dd> | ||
| Any character from the character set. Use <code>`</code> to escape special characters (e.g., <code>`</code>). | ||
| </dd> | ||
| </dl> | ||
|
|
||
| ### Examples | ||
|
|
||
| {% highlight sql %} | ||
| -- This CREATE TABLE fails with ParseException because of the illegal identifier name a.b | ||
| CREATE TABLE test (a.b int); | ||
| org.apache.spark.sql.catalyst.parser.ParseException: | ||
| no viable alternative at input 'CREATE TABLE test (a.'(line 1, pos 20) | ||
|
|
||
| -- This CREATE TABLE works | ||
| CREATE TABLE test (`a.b` int); | ||
|
|
||
| -- This CREATE TABLE fails with ParseException because special character ` is not escaped | ||
| CREATE TABLE test1 (`a`b` int); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should fail the parser?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This throws ParseException. Do you want me to change L71 to
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we include the error message in the example?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated. Thanks! |
||
| org.apache.spark.sql.catalyst.parser.ParseException: | ||
| no viable alternative at input 'CREATE TABLE test (`a`b`'(line 1, pos 23) | ||
|
|
||
| -- This CREATE TABLE works | ||
| CREATE TABLE test (`a``b` int); | ||
| {% endhighlight %} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to describe a multi-part name like
a.b.cfor DSv2? @cloud-fanUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still evolving, we don't mention anything about it in the sql reference for now.