From 57006762becc89b8aa96d25ee9896cc93fa2f7b2 Mon Sep 17 00:00:00 2001 From: Gal Salomon Date: Tue, 25 Jun 2024 19:31:01 +0300 Subject: [PATCH] fixing bug that produce wrong value upon empty string per some key. Signed-off-by: Gal Salomon --- include/s3select_json_parser.h | 10 +--------- include/s3select_oper.h | 16 +++++++++------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/include/s3select_json_parser.h b/include/s3select_json_parser.h index 03035ca8..f6ceeb80 100644 --- a/include/s3select_json_parser.h +++ b/include/s3select_json_parser.h @@ -640,12 +640,6 @@ class JsonParserHandler : public rapidjson::BaseReaderHandler, m_current_depth_non_anonymous++; } -#if 0 - if(from_clause.size() == 0 || std::equal(key_path.begin(), key_path.end(), from_clause.begin(), from_clause.end(), iequal_predicate)) { - prefix_match = true; - } -#endif - variable_match_operations.key(); return true; @@ -654,9 +648,7 @@ class JsonParserHandler : public rapidjson::BaseReaderHandler, void set_prefix_match(){ if(from_clause.size() == 0 || std::equal(key_path.begin(), key_path.end(), from_clause.begin(), from_clause.end(), iequal_predicate)) { - std::cout << "prefix_match = true :" << get_key_path() << std::endl; - prefix_match = true; //TODO it is not prefix in the case its a key/value . it is a prefix match in case it is key for array of key for object - //start-array , start-object can set the prefix match (from-clause match) + prefix_match = true; //it is not prefix_match in the case its a key/value . it is a prefix match in the case it is a key of array or key of an object } } diff --git a/include/s3select_oper.h b/include/s3select_oper.h index 9fd67b8b..01e7af3f 100644 --- a/include/s3select_oper.h +++ b/include/s3select_oper.h @@ -594,7 +594,7 @@ class value void set_json_key_path(std::vector& key_path) { - m_json_key = key_path; + m_json_key = key_path;//TODO not efficient } const char* to_string() //TODO very intensive , must improve this @@ -693,9 +693,10 @@ class value m_str_value = o.m_str_value; __val.str = m_str_value.data(); } - else if(o.__val.str) + else if(o.__val.str)//it is done upon using the set_string_nocopy { - __val.str = o.__val.str; + m_str_value.assign(o.__val.str);//need to create a copy for this + __val.str = m_str_value.data(); } } else @@ -717,9 +718,10 @@ class value m_str_value = o.m_str_value; __val.str = m_str_value.data(); } - else if(o.__val.str) + else if(o.__val.str)//it is done upon using the set_string_nocopy { - __val.str = o.__val.str; + m_str_value.assign(o.__val.str); + __val.str = m_str_value.data(); } } else @@ -1857,8 +1859,8 @@ class variable : public base_statement else { m_scratch->get_column_value(column_pos,var_value); - //in the case of successive column-delimiter {1,some_data,,3}=> third column is NULL - if (var_value.is_string() && (var_value.str()== 0 || (var_value.str() && *var_value.str()==0))){ + //in the case of successive column-delimiter {1,some_data,,3}=> third column is NULL(CSV data source) + if (!is_json_statement() && var_value.is_string() && (var_value.str()== 0 || (var_value.str() && *var_value.str()==0))){ var_value.setnull();//TODO is it correct for Parquet } }