Skip to content
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

YQ-3363 fix internal error for insert without params #8074

Merged
Show file tree
Hide file tree
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
9 changes: 8 additions & 1 deletion ydb/library/yql/providers/s3/provider/yql_s3_datasink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,19 @@ class TS3DataSinkProvider : public TDataProviderBase {
TExprNode::TPtr RewriteIO(const TExprNode::TPtr& write, TExprContext& ctx) override {
const TS3Write w(write);
auto settings = write->Tail().ChildrenList();

TExprNode::TPtr format = ExtractFormat(settings);
if (!format) {
ctx.AddError(TIssue(ctx.GetPosition(write->Pos()), "Missing format - please use WITH FORMAT when writing into S3"));
return nullptr;
}

return Build<TS3WriteObject>(ctx, w.Pos())
.World(w.World())
.DataSink(w.DataSink())
.Target<TS3Target>()
.Path(write->Child(2U)->Head().Tail().HeadPtr())
.Format(ExtractFormat(settings))
.Format(std::move(format))
.Settings(ctx.NewList(w.Pos(), std::move(settings)))
.Build()
.Input(write->ChildPtr(3))
Expand Down
25 changes: 25 additions & 0 deletions ydb/tests/fq/s3/test_insert.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,3 +510,28 @@ def test_insert_empty_object(self, kikimr, s3, client, unique_prefix):
assert result_set.columns[0].type.type_id == ydb.Type.STRING
assert len(result_set.rows) == 1
assert result_set.rows[0].items[0].text_value == ""

@yq_all
@pytest.mark.parametrize("client", [{"folder_id": "my_folder"}], indirect=True)
def test_insert_without_format_error(self, kikimr, s3, client, unique_prefix):
resource = boto3.resource(
"s3", endpoint_url=s3.s3_url, aws_access_key_id="key", aws_secret_access_key="secret_key"
)

bucket = resource.Bucket("insert_bucket")
bucket.create(ACL='public-read-write')
bucket.objects.all().delete()

storage_connection_name = unique_prefix + "ibucket"
client.create_storage_connection(storage_connection_name, "insert_bucket")

sql = f'''
insert into `{storage_connection_name}`.`/test/`
select * from AS_TABLE([<|foo:123, bar:"xxx"u|>,<|foo:456, bar:"yyy"u|>]);
'''

query_id = client.create_query("simple", sql, type=fq.QueryContent.QueryType.ANALYTICS).result.query_id
client.wait_query_status(query_id, fq.QueryMeta.FAILED)
issues = str(client.describe_query(query_id).result.query.issue)

assert "Missing format - please use WITH FORMAT when writing into S3" in issues, "Incorrect Issues: " + issues
Loading