Skip to content

Conversation

@Chenyu-Shi
Copy link
Contributor

finishing in expression. adding more tests and null support. need confirmation on null behavior and also I wonder why integer field is sufficient for string comparison. will bring this up at the meeting.

Copy link
Collaborator

@wzheng wzheng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partial review.

+ std::string(tuix::EnumNameFieldUnion(item->value_type())));
}
//TODO why integer field passing the string test
if (static_cast<const tuix::IntegerField *>(item->value())->value() == static_cast<const tuix::IntegerField *>(left->value())->value()){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might be forcibly casting here from string to integer, and the test passes because the integer values are the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used the dynamically comparison operator to fix this problem.


}

case tuix::ExprUnion_Concat:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you split this into a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry this is still in the same PR but both are somewhat complete now. I will look into splitting PR in the future.

Comment on lines 771 to 788
//TODO add null check

return tuix::CreateField(
builder,
tuix::FieldUnion_StringField,
tuix::CreateStringFieldDirect(
builder, &result, static_cast<uint32_t>(total)).Union(),
false);
/*
auto array_field = static_cast<const tuix::ArrayField *>(value->value());
std::string str = to_string(array_field);
std::vector<uint8_t> str_vec(str.begin(), str.end());
return tuix::CreateField(
builder,
tuix::FieldUnion_StringField,
tuix::CreateStringFieldDirect(builder, &str_vec, str_vec.size()).Union(),
result_is_null);
*/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually PRs don't include unfinished code or commented out code like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +977 to +983
case (Concat(child), childrenOffsets) =>
tuix.Expr.createExpr(
builder,
tuix.ExprUnion.Concat,
tuix.Concat.createConcat(
builder, tuix.Concat.createChildrenVector(builder, childrenOffsets.toArray)))

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put this in a separate PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry this is still in the same PR but both are somewhat complete now. I will look into splitting PR in the future.

bool result = false;

if (num_children < 2){
throw std::runtime_error(std::string("In can't operate with fewer than 2 args, currently we have")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this error be a bit more descriptive? What are the arguments that the In expression is expecting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

}

auto left_offset = eval_helper(row, (*c->children())[0]);
const tuix::Field *left = flatbuffers::GetTemporaryPointer(builder, left_offset);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to be able to handle NULL values, an example here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

size_t num_children = c->children()->size();
bool result = false;

if (num_children < 2){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify what kind of types IN handles? What if the user passes in a CalendarType?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used a dynamic typed comparison method that should work with different types

df.filter($"word".contains(lit("1"))).collect
}

testAgainstSpark("concatwithstring") { securityLevel =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you put spaces in the test name? Otherwise it's hard to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

df.select(concat(col("str"),lit(","),col("x"))).collect
}

testAgainstSpark("concatwithotherdatatype") { securityLevel =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change test name here too.

val df = makeDF(ids, securityLevel, "x", "y", "id")
val c = $"id" isin ($"x", $"y")
val result = df.filter(c)
//result.explain(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

val df2 = makeDF(ids2, securityLevel, "x", "y", "id")
val c2 = $"id" isin (1 ,2, 4, 5, 6)
val result = df2.filter(c2)
//result.explain(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

val df3 = makeDF(ids3, securityLevel, "x", "y", "id")
val c3 = $"id" isin ("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ,"b", "c", "d", "e")
val result = df3.filter(c3)
//result.explain(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

val df4 = makeDF(ids4, securityLevel, "x", "y", "id")
val c4 = $"id" isin (null.asInstanceOf[Int])
val result = df4.filter(c4)
//result.explain(true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

+ std::string(tuix::EnumNameFieldUnion(str->value_type()))
+ std::string(". You do not need to provide the data as string but the data should be serialized into string before sent to concat"));
}
if (!str->is_null()){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the final result NULL if any one value is NULL? If so, why do you need to go through concat with the non-NULL strings?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final result is not NULL if one value is null. It just skips over the null value. Modified a test to reflect this

Comment on lines +739 to +743
eval_binary_comparison<tuix::EqualTo, std::equal_to>(
builder,
flatbuffers::GetTemporaryPointer<tuix::Field>(builder, left_offset),
flatbuffers::GetTemporaryPointer<tuix::Field>(builder, right_offset)))
->value())->value();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work for every type, should you check for the supported type here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The eval_binary_comparison does the type checking and throws an type error if incompatible data type is passed in which is sufficient for type checking?

@wzheng
Copy link
Collaborator

wzheng commented Dec 19, 2020

Closing this PR since this has been split into #124 and #125.

@wzheng wzheng closed this Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants