-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9d70700
commit df5705e
Showing
4 changed files
with
96 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// This API is EXPERIMENTAL. | ||
|
||
#include "arrow/engine/substrait/extension_internal.h" | ||
|
||
#include "substrait/algebra.pb.h" | ||
|
||
namespace arrow { | ||
namespace engine { | ||
|
||
Status FromProto(const substrait::extensions::AdvancedExtension& extension, | ||
std::unordered_map<std::string, std::string>& out) { | ||
if (!extension.has_enhancement()) { | ||
return Status::Invalid("AdvancedExtension does not have enhancement"); | ||
} | ||
const auto& enhancement = extension.enhancement(); | ||
substrait::Expression_Literal literal; | ||
|
||
if (!enhancement.UnpackTo(&literal)) { | ||
return Status::Invalid("Unpack the literal failed"); | ||
} | ||
|
||
if (!literal.has_map()) { | ||
return Status::Invalid("Literal does not have map"); | ||
} | ||
auto literalMap = literal.map(); | ||
auto size = literalMap.key_values_size(); | ||
for (auto i = 0; i < size; i++) { | ||
substrait::Expression_Literal_Map_KeyValue keyValue = literalMap.key_values(i); | ||
out.emplace(keyValue.key().string(), keyValue.value().string()); | ||
} | ||
} | ||
} // namespace engine | ||
} // namespace arrow |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
// This API is EXPERIMENTAL. | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "arrow/compute/type_fwd.h" | ||
#include "arrow/engine/substrait/extension_set.h" | ||
#include "arrow/engine/substrait/options.h" | ||
#include "arrow/engine/substrait/relation.h" | ||
#include "arrow/engine/substrait/visibility.h" | ||
#include "arrow/result.h" | ||
#include "arrow/status.h" | ||
|
||
#include "substrait/extensions/extensions.pb.h" // IWYU pragma: export | ||
|
||
namespace arrow { | ||
namespace engine { | ||
|
||
/// Convert a Substrait ExtendedExpression to a vector of expressions and output names | ||
ARROW_ENGINE_EXPORT | ||
Status FromProto(const substrait::extensions::AdvancedExtension& extension, | ||
std::unordered_map<std::string, std::string>& out); | ||
|
||
} // namespace engine | ||
} // namespace arrow |
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