Skip to content

Commit

Permalink
Fixed expr-test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oss committed May 31, 2016
1 parent 23c1a68 commit 533e049
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion be/src/exprs/expr-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ExprTest : public testing::Test {
case TYPE_DOUBLE:
// Construct a StringValue from 'value'. 'value' must be valid for as long as
// this object is valid.
expr_value_.string_val = StringValue(value);
expr_value_.SetStringVal(value);
return &expr_value_.string_val;
case TYPE_TINYINT:
expr_value_.tinyint_val =
Expand Down
7 changes: 7 additions & 0 deletions be/src/exprs/expr-value.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ struct ExprValue {
return *this;
}

// Save string data to string_data
void SetStringVal(const std::string& str){
string_data=str;
string_val.ptr = const_cast<char*>(string_data.data());
string_val.len = string_data.size();
}

/// Sets the value for type to '0' and returns a pointer to the data
void* SetToZero(const ColumnType& type) {
switch (type.type) {
Expand Down
2 changes: 1 addition & 1 deletion be/src/exprs/literal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Literal::Literal(const TExprNode& node)
case TYPE_VARCHAR: {
DCHECK_EQ(node.node_type, TExprNodeType::STRING_LITERAL);
DCHECK(node.__isset.string_literal);
value_ = ExprValue(node.string_literal.value);
value_.SetStringVal(node.string_literal.value);
if (type_.type == TYPE_VARCHAR) {
value_.string_val.len = min(type_.len, value_.string_val.len);
}
Expand Down

0 comments on commit 533e049

Please sign in to comment.