-
Notifications
You must be signed in to change notification settings - Fork 29.2k
[SPARK-56984][DOCS] Document the SQL PATH feature #56040
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
Open
srielau
wants to merge
6
commits into
apache:master
Choose a base branch
from
srielau:SPARK-56984-document-path
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+866
−85
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
abfc56c
[SPARK-56984][DOCS] Document the SQL PATH feature
srielau 066802a
[SPARK-56984][DOCS][FOLLOWUP] Restructure SQL Path docs
srielau 8f6d8e2
[SPARK-56984][DOCS][FOLLOWUP] Tighten SQL Path doc copy and accuracy
srielau f1c1ba1
[SPARK-56984][DOCS][FOLLOWUP] Self-review accuracy fixes
srielau 5a72819
[SPARK-56984][DOCS][FOLLOWUP] Editorial pass on SQL Path docs
srielau d04ce7a
[SPARK-56984][DOCS][FOLLOWUP] Address review comments from @cloud-fan
srielau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| --- | ||
| layout: global | ||
| title: current_path function | ||
| displayTitle: current_path function | ||
| 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. | ||
| --- | ||
|
|
||
| Returns the effective SQL Path for the current session as a comma-separated string of | ||
| qualified namespace names. See [`SET PATH`](sql-ref-syntax-aux-conf-mgmt-set-path.html) for a | ||
| description of what the path is, how to enable it, and how to change it, and | ||
| [Name Resolution](sql-ref-name-resolution.html) for how the path drives unqualified name | ||
| resolution. | ||
|
|
||
| ### Syntax | ||
|
|
||
| ```sql | ||
| current_path() | ||
| ``` | ||
|
|
||
| ### Arguments | ||
|
|
||
| This function takes no arguments. The parentheses may be omitted. | ||
|
|
||
| ### Returns | ||
|
|
||
| A non-nullable `STRING`. Each path entry is written as a dotted name with backticks added only | ||
| where required by Spark's identifier rules. Entries are separated by a single comma. | ||
|
|
||
| When the path contains the virtual `CURRENT_SCHEMA` marker, the marker is materialized as the | ||
| catalog-qualified current schema (`current_catalog.current_schema`) each time | ||
| `current_path()` is evaluated, so subsequent `USE SCHEMA` statements are reflected without | ||
| re-issuing `SET PATH`. | ||
|
|
||
| ### Examples | ||
|
|
||
| ```sql | ||
| > SELECT current_path(); | ||
| system.builtin,system.session,spark_catalog.default | ||
|
|
||
| -- ANSI no-parens form returns the same value. | ||
| > SELECT CURRENT_PATH; | ||
| system.builtin,system.session,spark_catalog.default | ||
|
|
||
| -- The output reflects the latest SET PATH. | ||
| > SET PATH = spark_catalog.default, system.builtin; | ||
| > SELECT current_path(); | ||
| spark_catalog.default,system.builtin | ||
|
|
||
| -- CURRENT_SCHEMA on the path is re-evaluated on every call. | ||
| > SET PATH = CURRENT_SCHEMA, system.builtin; | ||
| > USE spark_catalog.finance; | ||
| > SELECT current_path(); | ||
| spark_catalog.finance,system.builtin | ||
| > USE spark_catalog.default; | ||
| > SELECT current_path(); | ||
| spark_catalog.default,system.builtin | ||
|
|
||
| -- Inside a persistent view or SQL function body, current_path() returns the invoker's path, | ||
| -- not the frozen path captured at creation time. | ||
| > SET PATH = spark_catalog.default, system.builtin; | ||
| > CREATE VIEW v_path AS SELECT current_path() AS p; | ||
| > SET PATH = spark_catalog.other, system.builtin; | ||
| > SELECT * FROM v_path; | ||
| spark_catalog.other,system.builtin | ||
| ``` | ||
|
|
||
| ### Related Statements | ||
|
|
||
| * [Name Resolution](sql-ref-name-resolution.html) | ||
| * [SET PATH](sql-ref-syntax-aux-conf-mgmt-set-path.html) | ||
| * [Built-in Functions](sql-ref-functions-builtin.html) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
"An unqualified 2-part reference" is in tension with the taxonomy this PR establishes in
sql-ref-name-resolution.md:273, which heads exactly this case as### Partially qualified (2 parts) — schema.object.describe-function.md:47(also new in this PR) just says "2-part names". A 2-part reference likebuiltin.xis partially qualified — it carries one level of qualifier (the schema), so calling it "unqualified" reads as self-contradictory.(Late catch — this wording was already in the prior review's snapshot and I should have flagged it then. Apologies for the second pass.)