Skip to content
This repository was archived by the owner on May 9, 2024. It is now read-only.

Commit 0405414

Browse files
committed
Add ENABLE_SQL build flag.
Signed-off-by: ienkovich <[email protected]>
1 parent 3ac48fe commit 0405414

File tree

4 files changed

+113
-44
lines changed

4 files changed

+113
-44
lines changed

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ include_directories(${SQLite3_INCLUDE_DIRS})
137137

138138
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
139139
option(ENABLE_PYTHON "Build Python libraries" ON)
140+
option(ENABLE_SQL "Enable SQL support" ON)
140141

141142
if(BUILD_SHARED_LIBS)
142143
add_definitions("-DENABLE_SHARED_LIBS")
@@ -487,7 +488,9 @@ add_custom_target(hdk_python_clean
487488
)
488489

489490
add_dependencies(clean-all hdk_python_clean)
490-
add_dependencies(clean-all calcite_java_clean)
491+
if (ENABLE_SQL)
492+
add_dependencies(clean-all calcite_java_clean)
493+
endif()
491494

492495

493496
option(ENABLE_TESTS "Build unit tests" ON)

omniscidb/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ if(BUILD_SHARED_LIBS)
138138
add_definitions("-DENABLE_SHARED_LIBS")
139139
endif()
140140

141+
option(ENABLE_SQL "Enable SQL support" ON)
142+
141143
# Required for macOS with Boost 1.71.0+
142144
# See https://gitlab.kitware.com/cmake/cmake/issues/19714
143145
if(APPLE)

omniscidb/Calcite/CMakeLists.txt

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,76 @@
1-
find_package(JNI REQUIRED)
2-
include_directories(${JNI_INCLUDE_DIRS})
3-
41
include_directories(${CMAKE_CURRENT_BINARY_DIR})
52

6-
## mvn process for java code
7-
find_program(MVN_EXECUTABLE NAMES mvn)
8-
if(NOT MVN_EXECUTABLE)
9-
message(FATAL_ERROR "mvn not found. Install Apache Maven.")
10-
endif()
11-
file(GLOB_RECURSE JAVA_POM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/**/pom.xml)
12-
file(GLOB_RECURSE JAVA_FTL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/calcite/src/main/codegen/includes/*.ftl)
13-
file(GLOB_RECURSE JAVA_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/**/*.java)
14-
list(FILTER JAVA_SOURCES EXCLUDE REGEX ".*/gen/.*")
15-
list(FILTER JAVA_SOURCES EXCLUDE REGEX ".*/generated-sources/.*")
3+
if(ENABLE_SQL)
4+
find_package(JNI REQUIRED)
5+
include_directories(${JNI_INCLUDE_DIRS})
166

17-
set(OMNISCI_JAR_RELEASE_VERSION "${MAPD_VERSION_MAJOR}.${MAPD_VERSION_MINOR}.${MAPD_VERSION_PATCH}")
18-
if("${MAPD_VERSION_EXTRA}" STREQUAL "dev")
19-
set (OMNISCI_JAR_RELEASE_VERSION "${OMNISCI_JAR_RELEASE_VERSION}-SNAPSHOT")
20-
endif()
7+
# # mvn process for java code
8+
find_program(MVN_EXECUTABLE NAMES mvn)
219

22-
if (WIN32)
23-
# "call" is needed on windows because "mvn" command is a batch script and without
24-
# "call" execution is transferred to it and is never returned back to this script.
25-
set(MVN_PATH_COMMAND call)
10+
if(NOT MVN_EXECUTABLE)
11+
message(FATAL_ERROR "mvn not found. Install Apache Maven.")
12+
endif()
2613

27-
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/bin" WIN_BIN_PATH)
28-
# The following call to cmd is required to ignore errors if directory already exitst
29-
set(MKDIR_COMMAND cmd /c "mkdir ${WIN_BIN_PATH} || (exit 0)")
30-
else()
31-
set(MVN_PATH_COMMAND "MVNPATH=${CMAKE_CURRENT_SOURCE_DIR}/java")
32-
set(MKDIR_COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin)
33-
endif()
14+
file(GLOB_RECURSE JAVA_POM RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/**/pom.xml)
15+
file(GLOB_RECURSE JAVA_FTL RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/calcite/src/main/codegen/includes/*.ftl)
16+
file(GLOB_RECURSE JAVA_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} java/**/*.java)
17+
list(FILTER JAVA_SOURCES EXCLUDE REGEX ".*/gen/.*")
18+
list(FILTER JAVA_SOURCES EXCLUDE REGEX ".*/generated-sources/.*")
19+
20+
set(OMNISCI_JAR_RELEASE_VERSION "${MAPD_VERSION_MAJOR}.${MAPD_VERSION_MINOR}.${MAPD_VERSION_PATCH}")
21+
22+
if("${MAPD_VERSION_EXTRA}" STREQUAL "dev")
23+
set(OMNISCI_JAR_RELEASE_VERSION "${OMNISCI_JAR_RELEASE_VERSION}-SNAPSHOT")
24+
endif()
3425

35-
add_custom_command(
36-
OUTPUT
26+
if(WIN32)
27+
# "call" is needed on windows because "mvn" command is a batch script and without
28+
# "call" execution is transferred to it and is never returned back to this script.
29+
set(MVN_PATH_COMMAND call)
30+
31+
file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/bin" WIN_BIN_PATH)
32+
33+
# The following call to cmd is required to ignore errors if directory already exitst
34+
set(MKDIR_COMMAND cmd /c "mkdir ${WIN_BIN_PATH} || (exit 0)")
35+
else()
36+
set(MVN_PATH_COMMAND "MVNPATH=${CMAKE_CURRENT_SOURCE_DIR}/java")
37+
set(MKDIR_COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin)
38+
endif()
39+
40+
add_custom_command(
41+
OUTPUT
3742
${CMAKE_BINARY_DIR}/bin/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar
3843
COMMAND ${MVN_PATH_COMMAND} ${MVN_EXECUTABLE} -l ${CMAKE_BINARY_DIR}/mvn_build.log -e clean install -Dmaven.compiler.showDeprecation=true -Dmaven.compiler.showWarnings=true -Domnisci.release.version="${OMNISCI_JAR_RELEASE_VERSION}" -Djava.net.preferIPv4Stack=true -Dmaven.wagon.http.retryHandler.count=3 -DMAPD_LOG_DIR="${CMAKE_BINARY_DIR}"
3944
COMMAND ${MKDIR_COMMAND}
4045
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/java/calcite/target/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar ${CMAKE_BINARY_DIR}/bin
4146
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java
42-
DEPENDS
47+
DEPENDS
4348
${CMAKE_CURRENT_SOURCE_DIR}/java/calcite/src/main/codegen/config.fmpp
4449
${CMAKE_CURRENT_SOURCE_DIR}/java/pom.xml
4550
${JAVA_POM}
4651
${JAVA_SOURCES}
4752
${JAVA_FTL}
4853
)
49-
add_custom_target(calcite_java_lib ALL DEPENDS
50-
${CMAKE_BINARY_DIR}/bin/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar)
51-
add_custom_target(calcite_java_clean
52-
COMMAND ${MVN_PATH_COMMAND} ${MVN_EXECUTABLE} -q clean -Domnisci.release.version="${OMNISCI_JAR_RELEASE_VERSION}"
53-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java
54+
add_custom_target(calcite_java_lib ALL DEPENDS
55+
${CMAKE_BINARY_DIR}/bin/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar)
56+
add_custom_target(calcite_java_clean
57+
COMMAND ${MVN_PATH_COMMAND} ${MVN_EXECUTABLE} -q clean -Domnisci.release.version="${OMNISCI_JAR_RELEASE_VERSION}"
58+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java
5459
)
5560

56-
add_custom_target(maven_populate_cache
57-
COMMAND ${MVN_PATH_COMMAND} ${MVN_EXECUTABLE} -q verify -Domnisci.release.version="${OMNISCI_JAR_RELEASE_VERSION}"
58-
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java
61+
add_custom_target(maven_populate_cache
62+
COMMAND ${MVN_PATH_COMMAND} ${MVN_EXECUTABLE} -q verify -Domnisci.release.version="${OMNISCI_JAR_RELEASE_VERSION}"
63+
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java
5964
)
6065

61-
add_library(Calcite CalciteAdapter.cpp CalciteJNI.cpp SchemaJson.cpp)
66+
add_library(Calcite CalciteAdapter.cpp CalciteJNI.cpp SchemaJson.cpp)
6267

63-
add_dependencies(Calcite calcite_java_lib)
68+
add_dependencies(Calcite calcite_java_lib)
6469

65-
target_link_libraries(Calcite PRIVATE IR OSDependent Shared ${JAVA_JVM_LIBRARY})
70+
target_link_libraries(Calcite PRIVATE IR OSDependent Shared ${JAVA_JVM_LIBRARY})
6671

67-
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/calcite/target/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar DESTINATION bin COMPONENT "jar")
72+
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/java/calcite/target/calcite-1.0-SNAPSHOT-jar-with-dependencies.jar DESTINATION bin COMPONENT "jar")
73+
else()
74+
add_library(Calcite CalciteStub.cpp SchemaJson.cpp)
75+
target_link_libraries(Calcite PRIVATE IR OSDependent Shared)
76+
endif()

omniscidb/Calcite/CalciteStub.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright (C) 2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include "CalciteJNI.h"
8+
9+
CalciteMgr::~CalciteMgr() {}
10+
11+
CalciteMgr* CalciteMgr::get(const std::string& udf_filename,
12+
const std::string& log_dir,
13+
size_t calcite_max_mem_mb) {
14+
std::call_once(instance_init_flag_, [=] {
15+
instance_ = std::unique_ptr<CalciteMgr>(
16+
new CalciteMgr(udf_filename, calcite_max_mem_mb, log_dir));
17+
});
18+
return instance_.get();
19+
}
20+
21+
std::string CalciteMgr::process(const std::string&,
22+
const std::string& sql_string,
23+
SchemaProvider*,
24+
Config*,
25+
const std::vector<FilterPushDownInfo>&,
26+
const bool,
27+
const bool,
28+
const bool) {
29+
static const std::string ra_prefix = "execute calcite";
30+
// For RA JSON queries simply remove the prefix and return.
31+
if (sql_string.substr(0, ra_prefix.size()) == ra_prefix) {
32+
return sql_string.substr(ra_prefix.size());
33+
}
34+
throw std::runtime_error("This HDK build doesn't include SQL support.");
35+
}
36+
37+
std::string CalciteMgr::getExtensionFunctionWhitelist() {
38+
return "[]";
39+
}
40+
41+
std::string CalciteMgr::getUserDefinedFunctionWhitelist() {
42+
return "[]";
43+
}
44+
45+
std::string CalciteMgr::getRuntimeExtensionFunctionWhitelist() {
46+
return "[]";
47+
}
48+
49+
void CalciteMgr::setRuntimeExtensionFunctions(const std::vector<ExtensionFunction>&,
50+
bool) {}
51+
52+
CalciteMgr::CalciteMgr(const std::string&, size_t, const std::string&) {}
53+
54+
std::once_flag CalciteMgr::instance_init_flag_;
55+
std::unique_ptr<CalciteMgr> CalciteMgr::instance_;

0 commit comments

Comments
 (0)