Use an expression visitor and serialization from #4308. #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a slightly different approach to
ExpressionParserthan in apache#5511.First, this adds
CustomOrderExpressionVisitorto separate the logic to traverse an expression from the logic to produce JSON from an expression node.Second, this updates the parser to use the serialization that was proposed in apache#4308 because there were some slight differences, like using
operandinstead ofchildinNot.Updating to the proposed JSON format introduced new challenges. The proposed format requires serializing expression values using single-value JSON serialization, but the existing parser for that serialization format requires a
Typeto decide how to serialize. To get a type, expressions must be bound before serializing.Binding an expression before serialization is probably a good idea because that will catch any issues with an unbound expression before sending it. If the expression can't be bound, it usually doesn't make sense to allow serializing it. However, it does make sense to serialize expressions that can't be bound on the remote side in some cases, like after an expression is sanitized and all the values are replaced with string descriptions (like
"(16-digit-int)").This implements bound expression serialization and deserialization, which requires passing a schema. Passing a schema allows using the
DefaultValueParserfor values and also works around the problem of deserializing transforms because the type can be known when deserializing.