Skip to content
Open
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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ option(VELOX_ENABLE_FILESYSTEM_CONNECTOR "Build FileSystem connector." ON)
option(VELOX_ENABLE_TPCH_CONNECTOR "Build TPC-H connector." ON)
option(VELOX_ENABLE_PRESTO_FUNCTIONS "Build Presto SQL functions." ON)
option(VELOX_ENABLE_SPARK_FUNCTIONS "Build Spark SQL functions." ON)
option(VELOX_ENABLE_FLINK_FUNCTIONS "Build Flink SQL functions." ON)
option(VELOX_ENABLE_EXPRESSION "Build expression." ON)
option(
VELOX_ENABLE_EXAMPLES
Expand Down Expand Up @@ -183,6 +184,7 @@ if(${VELOX_BUILD_MINIMAL} OR ${VELOX_BUILD_MINIMAL_WITH_DWIO})
set(VELOX_ENABLE_FILESYSTEM_CONNECTOR ON)
set(VELOX_ENABLE_TPCH_CONNECTOR OFF)
set(VELOX_ENABLE_SPARK_FUNCTIONS OFF)
set(VELOX_ENABLE_FLINK_FUNCTIONS OFF)
set(VELOX_ENABLE_EXAMPLES OFF)
set(VELOX_ENABLE_S3 OFF)
set(VELOX_ENABLE_GCS OFF)
Expand Down
4 changes: 4 additions & 0 deletions velox/functions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ if(${VELOX_ENABLE_SPARK_FUNCTIONS})
add_subdirectory(sparksql)
endif()

if(${VELOX_ENABLE_FLINK_FUNCTIONS})
add_subdirectory(flinksql)
endif()

if(${VELOX_ENABLE_REMOTE_FUNCTIONS})
add_subdirectory(remote)
endif()
Expand Down
17 changes: 17 additions & 0 deletions velox/functions/flinksql/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) Facebook, Inc. and its affiliates.
#
# Licensed 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.

velox_add_library(velox_functions_flink Register.cpp RegexFunctions.cpp)

velox_link_libraries(velox_functions_flink velox_functions_lib Folly::folly)
30 changes: 30 additions & 0 deletions velox/functions/flinksql/RegexFunctions.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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.
*/
#include "velox/functions/flinksql/RegexFunctions.h"

#include "velox/functions/lib/Re2Functions.h"

namespace facebook::velox::functions::flinksql {

std::shared_ptr<exec::VectorFunction> makeRegexExtract(
const std::string& name,
const std::vector<exec::VectorFunctionArg>& inputArgs,
const core::QueryConfig& config) {
// Flink semantics: returns NULL on no match, allows non-constant patterns.
return makeRe2Extract(name, inputArgs, config, /*emptyNoMatch=*/false);
}

} // namespace facebook::velox::functions::flinksql
33 changes: 33 additions & 0 deletions velox/functions/flinksql/RegexFunctions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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.
*/
#pragma once

#include <memory>
#include <vector>

#include "velox/expression/Expr.h"
#include "velox/vector/BaseVector.h"

namespace facebook::velox::functions::flinksql {

// Flink-flavored REGEXP_EXTRACT: returns NULL on no match, allows non-constant
// patterns.
std::shared_ptr<exec::VectorFunction> makeRegexExtract(
const std::string& name,
const std::vector<exec::VectorFunctionArg>& inputArgs,
const core::QueryConfig& config);

} // namespace facebook::velox::functions::flinksql
29 changes: 29 additions & 0 deletions velox/functions/flinksql/Register.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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.
*/
#include "velox/functions/flinksql/Register.h"

#include "velox/expression/VectorFunction.h"
#include "velox/functions/flinksql/RegexFunctions.h"
#include "velox/functions/lib/Re2Functions.h"

namespace facebook::velox::functions::flinksql {

void registerFunctions(const std::string& prefix) {
exec::registerStatefulVectorFunction(
prefix + "regexp_extract", re2ExtractSignatures(), makeRegexExtract);
}

} // namespace facebook::velox::functions::flinksql
29 changes: 29 additions & 0 deletions velox/functions/flinksql/Register.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* Licensed 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.
*/
#pragma once

#include <string>

namespace facebook::velox::functions::flinksql {

// Register Flink SQL functions.
//
// Idempotent within a process when called with overwrite=true at the
// exec::registerStatefulVectorFunction layer; existing registrations with the
// same name are replaced.
void registerFunctions(const std::string& prefix = "");

} // namespace facebook::velox::functions::flinksql
Loading