Skip to content

Commit 9ceb02f

Browse files
committed
Fixed location passing
1 parent f04c6ec commit 9ceb02f

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

ydb/core/external_sources/object_storage.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ struct TObjectStorageExternalSource : public IExternalSource {
4646

4747
virtual TString Pack(const NKikimrExternalSources::TSchema& schema,
4848
const NKikimrExternalSources::TGeneral& general) const override {
49-
TString location;
5049
NKikimrExternalSources::TObjectStorage objectStorage;
5150
for (const auto& [key, value]: general.attributes()) {
5251
auto lowerKey = to_lower(key);
@@ -63,14 +62,12 @@ struct TObjectStorageExternalSource : public IExternalSource {
6362
}
6463
} else if (IsIn({"file_pattern"sv, "data.interval.unit"sv, "data.datetime.format_name"sv, "data.datetime.format"sv, "data.timestamp.format_name"sv, "data.timestamp.format"sv, "csv_delimiter"sv}, lowerKey)) {
6564
objectStorage.mutable_format_setting()->insert({lowerKey, value});
66-
} else if (lowerKey == "location") {
67-
location = value;
6865
} else {
6966
ythrow TExternalSourceException() << "Unknown attribute " << key;
7067
}
7168
}
7269

73-
if (auto issues = Validate(schema, objectStorage, PathsLimit, location)) {
70+
if (auto issues = Validate(schema, objectStorage, PathsLimit, general.location())) {
7471
ythrow TExternalSourceException() << issues.ToString();
7572
}
7673

ydb/core/external_sources/object_storage_ut.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,21 @@ Y_UNIT_TEST_SUITE(ObjectStorageTest) {
3737

3838
{ // location
3939
NKikimrExternalSources::TGeneral general;
40-
general.mutable_attributes()->insert({"location", "}"});
40+
general.set_location("}");
4141
UNIT_ASSERT_EXCEPTION_CONTAINS(source->Pack(schema, general), NExternalSource::TExternalSourceException, "Location '}' contains invalid wildcard:");
4242
}
4343

4444
{ // file pattern
4545
NKikimrExternalSources::TGeneral general;
4646
general.mutable_attributes()->insert({"file_pattern", "}"});
4747
UNIT_ASSERT_EXCEPTION_CONTAINS(source->Pack(schema, general), NExternalSource::TExternalSourceException, "File pattern '}' contains invalid wildcard:");
48-
general.mutable_attributes()->insert({"location", "/test_file"});
48+
general.set_location("/test_file");
4949
UNIT_ASSERT_EXCEPTION_CONTAINS(source->Pack(schema, general), NExternalSource::TExternalSourceException, "Path pattern cannot be used with file_pattern");
5050
}
5151

5252
{ // partitioned by
5353
NKikimrExternalSources::TGeneral general;
54-
general.mutable_attributes()->insert({"location", "*"});
54+
general.set_location("*");
5555
general.mutable_attributes()->insert({"partitioned_by", "[year]"});
5656
UNIT_ASSERT_EXCEPTION_CONTAINS(source->Pack(schema, general), NExternalSource::TExternalSourceException, "Location '*' contains wildcards");
5757
}

ydb/core/kqp/gateway/utils/scheme_helpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ void FillCreateExternalTableColumnDesc(NKikimrSchemeOp::TExternalTableDescriptio
8888
columnDesc.SetNotNull(columnIt->second.NotNull);
8989
}
9090
NKikimrExternalSources::TGeneral general;
91+
general.set_location(settings.Location);
9192
auto& attributes = *general.mutable_attributes();
9293
for (const auto& [key, value]: settings.SourceTypeParameters) {
9394
attributes.insert({key, value});
9495
}
95-
attributes.insert({"location", settings.Location});
9696
externalTableDesc.SetContent(general.SerializeAsString());
9797
}
9898

ydb/core/protos/external_sources.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ message TSchema {
1111

1212
message TGeneral {
1313
map<string, string> attributes = 1 [(Ydb.size).le = 100];
14+
optional string location = 2;
1415
}
1516

1617
message TObjectStorage {

0 commit comments

Comments
 (0)