From 34bd756885b0e1707b9f8ec991020595c155f17d Mon Sep 17 00:00:00 2001 From: ienkovich Date: Wed, 11 Jan 2023 15:41:45 -0600 Subject: [PATCH] Move pg_shim call into CalciteJNI. Signed-off-by: ienkovich --- omniscidb/Calcite/CMakeLists.txt | 2 +- omniscidb/{QueryEngine => Calcite}/CalciteAdapter.cpp | 0 omniscidb/{QueryEngine => Calcite}/CalciteAdapter.h | 0 omniscidb/Calcite/CalciteJNI.cpp | 4 +++- omniscidb/QueryEngine/CMakeLists.txt | 1 - omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp | 3 +-- omniscidb/Tests/ArrowStorageSqlTest.cpp | 1 - omniscidb/Tests/NoCatalogSqlTest.cpp | 5 ++--- src/HDK.cpp | 9 ++++----- 9 files changed, 11 insertions(+), 14 deletions(-) rename omniscidb/{QueryEngine => Calcite}/CalciteAdapter.cpp (100%) rename omniscidb/{QueryEngine => Calcite}/CalciteAdapter.h (100%) diff --git a/omniscidb/Calcite/CMakeLists.txt b/omniscidb/Calcite/CMakeLists.txt index 1c7b78b186..a7abb8563a 100644 --- a/omniscidb/Calcite/CMakeLists.txt +++ b/omniscidb/Calcite/CMakeLists.txt @@ -50,7 +50,7 @@ add_custom_target(maven_populate_cache WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/java ) -add_library(Calcite CalciteJNI.cpp SchemaJson.cpp) +add_library(Calcite CalciteAdapter.cpp CalciteJNI.cpp SchemaJson.cpp) add_dependencies(Calcite calcite_java_lib) diff --git a/omniscidb/QueryEngine/CalciteAdapter.cpp b/omniscidb/Calcite/CalciteAdapter.cpp similarity index 100% rename from omniscidb/QueryEngine/CalciteAdapter.cpp rename to omniscidb/Calcite/CalciteAdapter.cpp diff --git a/omniscidb/QueryEngine/CalciteAdapter.h b/omniscidb/Calcite/CalciteAdapter.h similarity index 100% rename from omniscidb/QueryEngine/CalciteAdapter.h rename to omniscidb/Calcite/CalciteAdapter.h diff --git a/omniscidb/Calcite/CalciteJNI.cpp b/omniscidb/Calcite/CalciteJNI.cpp index a98c3787c7..77ffb2cffc 100644 --- a/omniscidb/Calcite/CalciteJNI.cpp +++ b/omniscidb/Calcite/CalciteJNI.cpp @@ -15,6 +15,7 @@ */ #include "CalciteJNI.h" +#include "CalciteAdapter.h" #include "SchemaJson.h" #include "Logger/Logger.h" @@ -194,7 +195,8 @@ class CalciteJNI::Impl { const bool is_view_optimize) { auto env = jvm_->getEnv(); jstring arg_catalog = env->NewStringUTF(db_name.c_str()); - jstring arg_query = env->NewStringUTF(sql_string.c_str()); + std::string modified_sql = pg_shim(sql_string); + jstring arg_query = env->NewStringUTF(modified_sql.c_str()); jobject arg_parsing_options = env->NewObject(parsing_opts_cls_, parsing_opts_ctor_, (jboolean)legacy_syntax, diff --git a/omniscidb/QueryEngine/CMakeLists.txt b/omniscidb/QueryEngine/CMakeLists.txt index cdb5e80211..dfcd1e27cd 100644 --- a/omniscidb/QueryEngine/CMakeLists.txt +++ b/omniscidb/QueryEngine/CMakeLists.txt @@ -15,7 +15,6 @@ set(query_engine_source_files ArrowResultSetConverter.cpp ArrowResultSet.cpp BitmapGenerators.cpp - CalciteAdapter.cpp CalciteDeserializerUtils.cpp CardinalityEstimator.cpp CaseIR.cpp diff --git a/omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp b/omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp index 6c0f7d1fb4..ef2e1979d1 100644 --- a/omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp +++ b/omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp @@ -18,7 +18,6 @@ #include "Calcite/CalciteJNI.h" #include "DataMgr/DataMgr.h" #include "DataMgr/DataMgrDataProvider.h" -#include "QueryEngine/CalciteAdapter.h" #include "QueryEngine/RelAlgExecutor.h" #include "SQLiteComparator.h" @@ -78,7 +77,7 @@ class ArrowSQLRunnerImpl { std::string query_ra; calcite_time_ += measure::execution( - [&]() { query_ra = rel_alg_cache_->process("test_db", pg_shim(sql), {}, true); }); + [&]() { query_ra = rel_alg_cache_->process("test_db", sql, {}, true); }); return query_ra; } diff --git a/omniscidb/Tests/ArrowStorageSqlTest.cpp b/omniscidb/Tests/ArrowStorageSqlTest.cpp index 143185f0a4..4a7a1c4735 100644 --- a/omniscidb/Tests/ArrowStorageSqlTest.cpp +++ b/omniscidb/Tests/ArrowStorageSqlTest.cpp @@ -17,7 +17,6 @@ #include "DataMgr/DataMgrBufferProvider.h" #include "DataMgr/DataMgrDataProvider.h" #include "QueryEngine/ArrowResultSet.h" -#include "QueryEngine/CalciteAdapter.h" #include "QueryEngine/RelAlgExecutor.h" #include "ArrowSQLRunner/ArrowSQLRunner.h" diff --git a/omniscidb/Tests/NoCatalogSqlTest.cpp b/omniscidb/Tests/NoCatalogSqlTest.cpp index 82bfadd6bc..19f0f696da 100644 --- a/omniscidb/Tests/NoCatalogSqlTest.cpp +++ b/omniscidb/Tests/NoCatalogSqlTest.cpp @@ -16,7 +16,6 @@ #include "DataMgr/DataMgrBufferProvider.h" #include "DataMgr/DataMgrDataProvider.h" #include "QueryEngine/ArrowResultSet.h" -#include "QueryEngine/CalciteAdapter.h" #include "QueryEngine/RelAlgExecutor.h" #include "SchemaMgr/SimpleSchemaProvider.h" #include "Shared/scope.h" @@ -188,12 +187,12 @@ class NoCatalogSqlTest : public ::testing::Test { } ExecutionResult runSqlQuery(const std::string& sql, Executor* executor) { - const auto query_ra = calcite_->process("test_db", pg_shim(sql)); + const auto query_ra = calcite_->process("test_db", sql); return runRAQuery(query_ra, executor); } RelAlgExecutor getExecutor(const std::string& sql) { - const auto query_ra = calcite_->process("test_db", pg_shim(sql)); + const auto query_ra = calcite_->process("test_db", sql); auto dag = std::make_unique( query_ra, TEST_DB_ID, schema_provider_, config_); return RelAlgExecutor( diff --git a/src/HDK.cpp b/src/HDK.cpp index 95197b56fe..537f2e6f6e 100644 --- a/src/HDK.cpp +++ b/src/HDK.cpp @@ -12,7 +12,6 @@ #include "Calcite/CalciteJNI.h" #include "DataMgr/DataMgr.h" #include "Logger/Logger.h" -#include "QueryEngine/CalciteAdapter.h" #include "QueryEngine/Execute.h" #include "QueryEngine/RelAlgExecutor.h" #include "Shared/Config.h" @@ -42,8 +41,8 @@ void HDK::read(std::shared_ptr& table, const std::string& table_na ExecutionResult HDK::query(const std::string& sql, const bool is_explain) { CHECK(internal_); CHECK(internal_->calcite); - auto ra = internal_->calcite->process( - internal_->db_name, pg_shim(sql), {}, /*legacy_syntax=*/true); + auto ra = + internal_->calcite->process(internal_->db_name, sql, {}, /*legacy_syntax=*/true); CHECK(internal_->storage); CHECK(internal_->config); @@ -88,8 +87,8 @@ HDK::HDK() : internal_(std::make_unique()) { SystemParameters sys_params; - internal_->data_mgr = std::make_shared( - *internal_->config.get(), sys_params); + internal_->data_mgr = + std::make_shared(*internal_->config.get(), sys_params); internal_->data_mgr->getPersistentStorageMgr()->registerDataProvider( internal_->schema_id, internal_->storage);