-
Notifications
You must be signed in to change notification settings - Fork 49
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
fix: Always use get_src_tbl_names()
to fetch tbl Id
s within dm_from_con()
#1934
Draft
owenjonesuob
wants to merge
2
commits into
cynkra:main
Choose a base branch
from
owenjonesuob:b-dm-from-con-name-pattern
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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
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.
When using schemas this code fails as well, since
table_names
normally does not include the schema, yetnames(tbl_ids)
does.Therefore, I would suggest to replace lines 96-109 with the following:
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.
Many thanks for this!! I hadn't spotted the
*_tbl_access()
functions, those look super handy 😁 I'll certainly adjust to include those.Regarding
table_names
, I've just been thinking about the following situation:Suppose there is a table name which exists in multiple schemas, e.g. suppose
schema1.table1
andschema2.table1
both exist.Now if a user asks for:
What should we return in such a case?
One option would be for the user to provide
"schema.table"
-format names intable_names
. The documentation fortable_names
would perhaps need some adjustment - but:schema.table
syntax - see discussion in comment here feat:dm_from_con()
gains.names
argument for pattern-based construction of table names in the dm object #1790 (comment)names(tbl_ids)
implementation?Or maybe we should include both
schema1.table1
andschema2.table1
in the returneddm
object; which I think is what your suggested changes will result in? I'm conflicted about this, because I feel like once we start dealing with multiple schemas, we should always be explicit about those schemas - but maybe that's just me being too strict with SQL ideals 😛To offer one more alternative, we could include only the first table found with that name, and then raising a warning, as described here? #1789 (comment)
I'll happily proceed with whichever you think is best!
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.
Thanks for your reply, good catch about the same table name in different schemas.
In my opinion, if the user provides 1 table name and more than 1 schema name, as in your example, this should lead to an error: either
schema
is not provided, has length 1 or needs to have a length matching the length oftable_names
.names(tbl_ids)
is a vector of the resulting names in the dm according to the specification in the.names
argument. In caseschema
is given with multiple schema names, the default for this argument -- as you know -- is "{.schema}.{.table}", which leads todm
-tables just like you suggested (schema1.table1
andschema2.table1
), if the user gavetable_names = c("table1", "table1")
andschema = c("schema1", "schema2")
.In general
names(tbl_ids)
could be anything though and for this reason it cannot be used in any conditions.I think the error messages need to be adapted to include the schema names of the tables that could not be accessed.
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.
Okidoki! So based on these comments so far, I think we might need to modify how
table_names
works, such that it can accept a list in the multiple-schemas case - something like:I'll make one more case for leaving things as they are currently implemented, i.e. based on
names(tbl_ids)
, because it avoids adding complexity totable_names
.True - but names are always constructed using the
.names
pattern, which is either the default (which multi-schema users must be aware of already), or specified by the user!So the user does always know how elements of the returned
dm
object will be named; and therefore they know how the strings intable_names
should look.Thinking back to before multiple schema functionality was added, I think one interpretation of
table_names
was:And I think that with this implementation, that interpretation is still valid now in the multi-schema case.
What do you think? For either of those approaches, I reckon I now have a solid specification to go away and implement 😇 many thanks for your patience and guidance with this one!