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

Commit

Permalink
Move pg_shim call into CalciteJNI.
Browse files Browse the repository at this point in the history
Signed-off-by: ienkovich <[email protected]>
  • Loading branch information
ienkovich committed Jan 11, 2023
1 parent 0a5c9d8 commit 34bd756
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion omniscidb/Calcite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
File renamed without changes.
4 changes: 3 additions & 1 deletion omniscidb/Calcite/CalciteJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "CalciteJNI.h"
#include "CalciteAdapter.h"
#include "SchemaJson.h"

#include "Logger/Logger.h"
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion omniscidb/QueryEngine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ set(query_engine_source_files
ArrowResultSetConverter.cpp
ArrowResultSet.cpp
BitmapGenerators.cpp
CalciteAdapter.cpp
CalciteDeserializerUtils.cpp
CardinalityEstimator.cpp
CaseIR.cpp
Expand Down
3 changes: 1 addition & 2 deletions omniscidb/Tests/ArrowSQLRunner/ArrowSQLRunner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -78,7 +77,7 @@ class ArrowSQLRunnerImpl {
std::string query_ra;

calcite_time_ += measure<std::chrono::microseconds>::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;
}
Expand Down
1 change: 0 additions & 1 deletion omniscidb/Tests/ArrowStorageSqlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 2 additions & 3 deletions omniscidb/Tests/NoCatalogSqlTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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<RelAlgDagBuilder>(
query_ra, TEST_DB_ID, schema_provider_, config_);
return RelAlgExecutor(
Expand Down
9 changes: 4 additions & 5 deletions src/HDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -42,8 +41,8 @@ void HDK::read(std::shared_ptr<arrow::Table>& 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);
Expand Down Expand Up @@ -88,8 +87,8 @@ HDK::HDK() : internal_(std::make_unique<Internal>()) {

SystemParameters sys_params;

internal_->data_mgr = std::make_shared<Data_Namespace::DataMgr>(
*internal_->config.get(), sys_params);
internal_->data_mgr =
std::make_shared<Data_Namespace::DataMgr>(*internal_->config.get(), sys_params);
internal_->data_mgr->getPersistentStorageMgr()->registerDataProvider(
internal_->schema_id, internal_->storage);

Expand Down

0 comments on commit 34bd756

Please sign in to comment.