-
Notifications
You must be signed in to change notification settings - Fork 25.6k
SQL: change the way unsupported data types fields are handled #50823
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
Changes from all commits
b2b553a
920e143
ba09e3e
007d6cd
c1809e5
0e51f43
330557d
1d1d5da
a9e9296
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,7 +73,7 @@ private static void walkMapping(String name, Object value, Map<String, EsField> | |
| properties = Collections.emptyMap(); | ||
| } | ||
| } else { | ||
| properties = Collections.emptyMap(); | ||
| properties = fromEs(content); | ||
| } | ||
| boolean docValues = boolSetting(content.get("doc_values"), esDataType.defaultDocValues); | ||
| final EsField field; | ||
|
|
@@ -91,7 +91,8 @@ private static void walkMapping(String name, Object value, Map<String, EsField> | |
| break; | ||
| case UNSUPPORTED: | ||
| String type = content.get("type").toString(); | ||
| field = new UnsupportedEsField(name, type); | ||
| field = new UnsupportedEsField(name, type, null, properties); | ||
| propagateUnsupportedType(name, type, properties); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is propagated needed? The parents should always be discovered before children which means an unsupported parent will discovered before its children, which in turn, will already know their parent is unsupported and thus become unsupported as well.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @costin If I remember well, the method pair Then after discovering all the children, create the parent itself here. So, by the time the algorithm finds out that a root field is unsupported, the children already have some types (their own).
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This approach is used only in the case of some tests that use a |
||
| break; | ||
| default: | ||
| field = new EsField(name, esDataType, properties, docValues); | ||
|
|
@@ -113,4 +114,21 @@ private static boolean boolSetting(Object value, boolean defaultValue) { | |
| private static int intSetting(Object value, int defaultValue) { | ||
| return value == null ? defaultValue : Integer.parseInt(value.toString()); | ||
| } | ||
|
|
||
| private static void propagateUnsupportedType(String inherited, String originalType, Map<String, EsField> properties) { | ||
| if (properties != null && properties.isEmpty() == false) { | ||
| for (Entry<String, EsField> entry : properties.entrySet()) { | ||
| EsField field = entry.getValue(); | ||
| UnsupportedEsField u; | ||
| if (field instanceof UnsupportedEsField) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the |
||
| u = (UnsupportedEsField) field; | ||
| u = new UnsupportedEsField(u.getName(), originalType, inherited, u.getProperties()); | ||
| } else { | ||
| u = new UnsupportedEsField(field.getName(), originalType, inherited, field.getProperties()); | ||
| } | ||
| entry.setValue(u); | ||
| propagateUnsupportedType(inherited, originalType, u.getProperties()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,9 @@ | |
| "time_frame" : { | ||
| "type" : "date_range", | ||
| "format" : "yyyy-MM-dd" | ||
| }, | ||
| "flat" : { | ||
| "type" : "flattened" | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,8 +217,14 @@ private static Attribute handleSpecialFields(UnresolvedAttribute u, Attribute na | |
| // unsupported types | ||
| else if (DataTypes.isUnsupported(fa.dataType())) { | ||
| UnsupportedEsField unsupportedField = (UnsupportedEsField) fa.field(); | ||
| named = u.withUnresolvedMessage( | ||
| "Cannot use field [" + fa.name() + "] type [" + unsupportedField.getOriginalType() + "] as is unsupported"); | ||
| if (unsupportedField.hasInherited()) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the message is the same in the branch, simply do the if on the prefix Further more replace the string concatenation in the message with |
||
| named = u.withUnresolvedMessage( | ||
| "Cannot use field [" + fa.name() + "] with unsupported type [" + unsupportedField.getOriginalType() + "] " | ||
| + "in hierarchy (field [" + unsupportedField.getInherited() + "])"); | ||
| } else { | ||
| named = u.withUnresolvedMessage( | ||
| "Cannot use field [" + fa.name() + "] with unsupported type [" + unsupportedField.getOriginalType() + "]"); | ||
| } | ||
| } | ||
| // compound fields | ||
| else if (allowCompound == false && fa.dataType().isPrimitive() == false) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole block can be further simplified by