-
Notifications
You must be signed in to change notification settings - Fork 91
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
query: remove support for saving dataset query with a given name #389
Merged
Merged
Changes from all commits
Commits
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,23 +100,22 @@ def test_query_cli(cloud_test_catalog_tmpfile, tmp_path, catalog_info_filepath, | |
from datachain import C | ||
from datachain.sql.functions.path import name | ||
|
||
DatasetQuery({src_uri!r}, catalog=catalog).mutate(name=name(C.path)) | ||
DatasetQuery({src_uri!r}, catalog=catalog).mutate(name=name(C.path)).save("my-ds") | ||
""" | ||
query_script = setup_catalog(query_script, catalog_info_filepath) | ||
|
||
filepath = tmp_path / "query_script.py" | ||
filepath.write_text(query_script) | ||
|
||
ds_name = "my-dataset" | ||
query(catalog, str(filepath), ds_name, columns=["name"]) | ||
query(catalog, str(filepath), columns=["name"]) | ||
captured = capsys.readouterr() | ||
|
||
header, *rows = captured.out.splitlines() | ||
assert header.strip() == "name" | ||
name_rows = {row.split()[1] for row in rows} | ||
assert name_rows == {"cat1", "cat2", "description", "dog1", "dog2", "dog3", "dog4"} | ||
|
||
dataset = catalog.get_dataset(ds_name) | ||
dataset = catalog.get_dataset("my-ds") | ||
assert dataset | ||
result_job_id = dataset.get_version(dataset.latest_version).job_id | ||
assert result_job_id | ||
|
@@ -153,7 +152,7 @@ def test_query_cli_no_dataset_returned( | |
QueryScriptRunError, | ||
match="Last line in a script was not an instance of DataChain", | ||
): | ||
query(catalog, str(filepath), "my-dataset", columns=["name"]) | ||
query(catalog, str(filepath), columns=["name"]) | ||
|
||
latest_job = get_latest_job(catalog.metastore) | ||
assert latest_job | ||
|
@@ -166,17 +165,12 @@ def test_query_cli_no_dataset_returned( | |
|
||
|
||
@pytest.mark.parametrize( | ||
"save,save_as", | ||
( | ||
(True, None), | ||
(None, "my-dataset"), | ||
(True, "my-dataset"), | ||
), | ||
"save", | ||
(True, False), | ||
) | ||
@pytest.mark.parametrize("save_dataset", (None, "new-dataset")) | ||
def test_query( | ||
save, | ||
save_as, | ||
save_dataset, | ||
cloud_test_catalog_tmpfile, | ||
tmp_path, | ||
|
@@ -194,11 +188,12 @@ def test_query( | |
""" | ||
query_script = setup_catalog(query_script, catalog_info_filepath) | ||
|
||
result = catalog.query(query_script, save=save, save_as=save_as) | ||
if save_as: | ||
assert result.dataset.name == save_as | ||
assert catalog.get_dataset(save_as) | ||
elif save_dataset: | ||
result = catalog.query(query_script, save=save) | ||
if not save: | ||
assert result.dataset is None | ||
return | ||
Comment on lines
+192
to
+194
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. Previous test did not test with I am only testing this just to make parametrization easier. #360 will require adjusting these anyway. |
||
|
||
if save_dataset: | ||
assert result.dataset.name == save_dataset | ||
assert catalog.get_dataset(save_dataset) | ||
else: | ||
|
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.
This API is no longer used after removing
save_as
logic fromquery_wrapper
below, so I have removed it.