Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESQL: Fix for overzealous validation in case of invalid mapped fields #111475

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c04e39c
Quick fix: make validation more lenient
alex-spies Jul 31, 2024
a4f1bdc
Fix csv test
alex-spies Jul 31, 2024
f7a536f
Disallow union types EXCEPT when they're cast
alex-spies Jul 31, 2024
6cb8d42
Add capability for the fix
alex-spies Jul 31, 2024
1cee60c
Fix message on invalid union types for conversion
alex-spies Aug 2, 2024
f9746c1
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 2, 2024
ecc39f2
Skip csv test unless run as IT
alex-spies Aug 2, 2024
103234a
Add tests for KEEP
alex-spies Aug 2, 2024
d17c44c
More tests
alex-spies Aug 2, 2024
eda9446
Even more tests
alex-spies Aug 2, 2024
fa910df
Update docs/changelog/111475.yaml
alex-spies Aug 2, 2024
ef80364
Update docs/changelog/111475.yaml
alex-spies Aug 2, 2024
6cee3a7
Update capabilities in tests
alex-spies Aug 2, 2024
6e3ecb8
Do not use UnresolvedAttribute without a field
alex-spies Aug 5, 2024
434f587
Revert Analyzer to main
alex-spies Aug 5, 2024
b7f9d04
More tests
alex-spies Aug 5, 2024
7661582
Simpler approach
alex-spies Aug 5, 2024
68b6e13
Remove test again
alex-spies Aug 5, 2024
da2195f
Fix bug in ResolveRefs, update tests
alex-spies Aug 5, 2024
4338849
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 5, 2024
57d6ada
Fix resolveStats
alex-spies Aug 6, 2024
0d88427
One more test
alex-spies Aug 6, 2024
944e3bd
Remove toAttributeUnchecked
alex-spies Aug 6, 2024
57412f5
Another approach: make TO_IP(client_ip) resolved
alex-spies Aug 6, 2024
a18846c
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 6, 2024
53ea113
Make test skip more lenient
alex-spies Aug 6, 2024
c324bc6
Update docs
alex-spies Aug 6, 2024
6be0256
Minor refactor
alex-spies Aug 6, 2024
9a871a8
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 6, 2024
850d2b0
Add test
alex-spies Aug 6, 2024
a0d1360
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 7, 2024
9a265e2
D'oh
alex-spies Aug 7, 2024
0d36a41
Fix RENAME for unsupported/multi-typed fields
alex-spies Aug 7, 2024
62a9615
Continue validation after RENAME multityped AS foo
alex-spies Aug 7, 2024
92d1e48
Address Andrei's remarks
alex-spies Aug 7, 2024
97c90ac
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 7, 2024
76e1301
Invalidate UnsupportedAttribute in RENAME
alex-spies Aug 7, 2024
b06f6a2
Add verifier test
alex-spies Aug 8, 2024
e268dea
Remove csv test
alex-spies Aug 8, 2024
63d1847
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 8, 2024
d1fb6a9
Checkstyle
alex-spies Aug 8, 2024
a4b1819
Use lower cased type name in ENRICH validation msg
alex-spies Aug 8, 2024
4481bbd
Remove obsolete tests
alex-spies Aug 8, 2024
15b00a8
D'oh
alex-spies Aug 8, 2024
8818fae
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 8, 2024
91bdd54
Remove leftover
alex-spies Aug 8, 2024
35ca062
Merge remote-tracking branch 'upstream/main' into fix-union-types-bre…
alex-spies Aug 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;

Expand Down Expand Up @@ -79,6 +80,17 @@ public AttributeSet references() {
// pass Object.class as a type token to pick Collections of expressions not just expressions
//

public <E extends Expression> PlanType transformExpressionsOnlyUsingParent(
Class<E> typeToken,
BiFunction<Expression, Expression, ? extends Expression> rule
) {
return transformPropertiesOnly(Object.class, e -> doTransformExpression(e, exp -> exp.transformDownUsingParent(typeToken, rule)));
}

public PlanType transformExpressionsOnlyUsingParent(BiFunction<Expression, Expression, ? extends Expression> rule) {
return transformPropertiesOnly(Object.class, e -> doTransformExpression(e, exp -> exp.transformDownUsingParent(rule)));
}

public PlanType transformExpressionsOnly(Function<Expression, ? extends Expression> rule) {
return transformPropertiesOnly(Object.class, e -> doTransformExpression(e, exp -> exp.transformDown(rule)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
Expand Down Expand Up @@ -172,6 +173,24 @@ protected void doCollectFirst(Predicate<? super T> predicate, List<T> matches) {
// transform the node itself and its children
//

@SuppressWarnings("unchecked")
public <E extends T> T transformDownUsingParent(Class<E> typeToken, BiFunction<? super T, ? super T, ? extends T> rule) {
return transformDownUsingParent((t, parent) -> (typeToken.isInstance(t) ? rule.apply((E) t, parent) : t), null);
}

@SuppressWarnings("unchecked")
public T transformDownUsingParent(BiFunction<? super T, ? super T, ? extends T> rule) {
return transformDownUsingParent(rule, null);
}

@SuppressWarnings("unchecked")
public T transformDownUsingParent(BiFunction<? super T, ? super T, ? extends T> rule, T parent) {
T root = rule.apply((T) this, parent);
Node<T> node = this.equals(root) ? this : root;

return node.transformChildren(child -> child.transformDownUsingParent(rule, (T) node));
}

@SuppressWarnings("unchecked")
public T transformDown(Function<? super T, ? extends T> rule) {
T root = rule.apply((T) this);
Expand All @@ -186,6 +205,23 @@ public <E extends T> T transformDown(Class<E> typeToken, Function<E, ? extends T
return transformDown((t) -> (typeToken.isInstance(t) ? rule.apply((E) t) : t));
}

@SuppressWarnings("unchecked")
public <E extends T> T transformUpUsingParent(Class<E> typeToken, BiFunction<? super T, ? super T, ? extends T> rule) {
return transformUpUsingParent((t, parent) -> (typeToken.isInstance(t) ? rule.apply((E) t, parent) : t), null);
}

@SuppressWarnings("unchecked")
public T transformUpUsingParent(BiFunction<? super T, ? super T, ? extends T> rule) {
return transformUpUsingParent(rule, null);
}

@SuppressWarnings("unchecked")
public T transformUpUsingParent(BiFunction<? super T, ? super T, ? extends T> rule, T parent) {
T transformed = transformChildren(child -> child.transformUpUsingParent(rule, (T) this));
T node = this.equals(transformed) ? (T) this : transformed;
return rule.apply(node, parent);
}

@SuppressWarnings("unchecked")
public T transformUp(Function<? super T, ? extends T> rule) {
T transformed = transformChildren(child -> child.transformUp(rule));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1015,3 +1015,17 @@ client_ip:ip | event_duration:long | message:keyword | @timestamp:keywo
;

# Once INLINESTATS supports expressions in agg functions and groups, convert the group in the inlinestats

multiIndexNoUnionRename
// TODO: union types not really required, this is only needed because csv tests currently can't load more than one
// index/csv.
required_capability: union_types
FROM sample_data, sample_data_ts_long
| RENAME message AS event_message
| SORT client_ip ASC
| LIMIT 1
;

@timestamp:null | client_ip:ip | event_duration:long | event_message:keyword
2023-10-23T13:33:34.937Z | 172.21.0.5 | 1232382 | Disconnected
;
Loading