Skip to content

Commit

Permalink
fixing bug that produce wrong value upon empty string per some key.
Browse files Browse the repository at this point in the history
Signed-off-by: Gal Salomon <[email protected]>
  • Loading branch information
galsalomon66 committed Jun 25, 2024
1 parent 9c45f98 commit 5700676
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
10 changes: 1 addition & 9 deletions include/s3select_json_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,6 @@ class JsonParserHandler : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,
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;
Expand All @@ -654,9 +648,7 @@ class JsonParserHandler : public rapidjson::BaseReaderHandler<rapidjson::UTF8<>,

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
}
}

Expand Down
16 changes: 9 additions & 7 deletions include/s3select_oper.h
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ class value

void set_json_key_path(std::vector<std::string>& 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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit 5700676

Please sign in to comment.