Skip to content

basic_example_v1: added comments on TablePathPrefix usage to avoid confusion #44

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

Merged
merged 2 commits into from
Aug 24, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions examples/basic_example_v1/basic_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
import ydb
import basic_example_data

# Table path prefix allows to put the working tables into the specific directory
# inside the YDB database. Putting `PRAGMA TablePathPrefix("some/path")`
# at the beginning of the query allows to reference the tables through
# their names "under" the specified directory.
#
# TablePathPrefix can be defined as an absolute path (starting with slash),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrase is interesting, does table path prefix supports relative path for YDB?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This phrase is interesting, does table path prefix supports relative path for YDB?

Good point. Seems that I was confused by the docs, in particular with that thing: https://ydb.tech/ru/docs/yql/reference/syntax/pragma#table-path-prefix

Hard to understand why does it need the database part on the first place...

# or as a relative path. Absolute path has to be started with the current
# database location.
#
# https://ydb.tech/ru/docs/yql/reference/syntax/pragma#table-path-prefix

FillDataQuery = """PRAGMA TablePathPrefix("{}");

DECLARE $seriesData AS List<Struct<
Expand Down Expand Up @@ -309,6 +320,8 @@ def run(endpoint, database, path):

ensure_path_exists(driver, database, path)

# absolute path - prefix to the table's names,
# including the database location
full_path = posixpath.join(database, path)

create_tables(pool, full_path)
Expand Down