-
Notifications
You must be signed in to change notification settings - Fork 25k
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
SQL: Support pattern against compatible indices #34718
Conversation
Extend querying support on multiple indices from being strictly identical to being just compatible. Use FieldCapabilities API (extended through elastic#33803) for mapping merging. Close elastic#31837 elastic#31611
Pinging @elastic/es-search-aggs |
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.
LGTM. Left some really minor comments, mostly based on picky concerns.
} | ||
if (fieldCap.isSearchable() && fieldCap.nonSearchableIndices() != null) { | ||
errorMessage.append("[" + indexPattern + "] points to indices with incompatible mappings: "); | ||
errorMessage.append("field [" + name + "] is searchable expect in "); |
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.
Typo for expect
, should have been except
.
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.
Fixed.
case KEYWORD: | ||
int length = DataType.KEYWORD.defaultPrecision; | ||
boolean normalized = false; | ||
field = new KeywordEsField(fieldName, props, caps.isAggregatable(), length, normalized); |
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.
Why just not passing false
to the constructor, but using the normalized
boolean?
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.
Mainly to not forget about it - I've added a comment regarding its presence.
EsField field = null; | ||
Map<String, EsField> props = hasChildren ? new TreeMap<>() : emptyMap(); | ||
|
||
// not currently present, means it's a parent field - currently just return it as an OBJECT |
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.
I don't understand this comment. This should be a valid statement when there is no dot (no subfields left), but the line it's put before of, doesn't indicate this assumption? Sorry if I missed anything.
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.
Old comment, irrelevant. Removed it.
@@ -40,7 +41,8 @@ public void testSelectFromIndexWithoutTypes() throws Exception { | |||
|
|||
try (Connection c = esJdbc()) { | |||
SQLException e = expectThrows(SQLException.class, () -> c.prepareStatement("SELECT * FROM test").executeQuery()); | |||
assertEquals("Found 1 problem(s)\nline 1:15: [test] doesn't have any types so it is incompatible with sql", e.getMessage()); | |||
//assertEquals("Found 1 problem(s)\nline 1:15: [test] doesn't have any types so it is incompatible with sql", e.getMessage()); |
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.
Why not deleting this line altogether?
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.
@@ -219,7 +219,8 @@ public void testSelectFromIndexWithoutTypes() throws Exception { | |||
client().performRequest(request); | |||
String mode = randomFrom("jdbc", "plain"); | |||
expectBadRequest(() -> runSql(mode, "SELECT * FROM test"), | |||
containsString("1:15: [test] doesn't have any types so it is incompatible with sql")); | |||
//containsString("1:15: [test] doesn't have any types so it is incompatible with sql")); |
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.
Same here
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.
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.
Looks Good!!
Minor and just a personal preference: I don't like so much the caps
abbreviation for capabilities because it's commonly used for capitalisation
. I don't have a good suggestion though... maybe capbs
:-) ?
Also left a question for the error message testing.
} | ||
|
||
// Concrete indices still uses get mapping |
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.
maybe add a TODO to be more clear?
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.
it's rather WIP blocked by : #34071
As this is high on my list, I'd like that as is instead of a TODO
(which typically suggests uncompleted work) - fro 6.5.x there's no much we can do on this front...
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java
Show resolved
Hide resolved
x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java
Show resolved
Hide resolved
} | ||
|
||
// Concrete indices still uses get mapping |
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.
Maybe add a TODO
to be more clear?
if (errorMessage.length() > 0) { | ||
errorMessage.append(", "); | ||
} | ||
errorMessage.append("["); |
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.
Is this tested with multiple entries?
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.
If you're asking about the error message, yes in IndexResolverTests
(e.g. testMergeIncompatibleTypes
).
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.
I was confused with the StringBuilder here, as you later on insert(0
for the prefix of the message.
You could use an ArrayList for the type.getKey()
and a StringJoiner to append them to the StringBuilder.
Really minor, just a suggestion.
@matriv fieldCaps is already used inside the public API and through-out the code. I guess it's just another case of overloading : see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-field-caps.html (the API name is |
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.
LGTM!!
* master: (24 commits) ingest: better support for conditionals with simulate?verbose (elastic#34155) [Rollup] Job deletion should be invoked on the allocated task (elastic#34574) [DOCS] .Security index is never auto created (elastic#34589) CCR: Requires soft-deletes on the follower (elastic#34725) re-enable bwc tests (elastic#34743) Empty GetAliases authorization fix (elastic#34444) INGEST: Document Processor Conditional (elastic#33388) [CCR] Add total fetch time leader stat (elastic#34577) SQL: Support pattern against compatible indices (elastic#34718) [CCR] Auto follow pattern APIs adjustments (elastic#34518) [Test] Remove dead code from ExceptionSerializationTests (elastic#34713) A small typo in migration-assistance doc (elastic#34704) ingest: processor stats (elastic#34724) SQL: Implement IN(value1, value2, ...) expression. (elastic#34581) Tests: Add checks to GeoDistanceQueryBuilderTests (elastic#34273) INGEST: Rename Pipeline Processor Param. (elastic#34733) Core: Move IndexNameExpressionResolver to java time (elastic#34507) [DOCS] Force Merge: clarify execution and storage requirements (elastic#33882) TESTING.asciidoc fix examples using forbidden annotation (elastic#34515) SQL: Implement `CONVERT`, an alternative to `CAST` (elastic#34660) ...
Extend querying support on multiple indices from being strictly
identical to being just compatible.
Use FieldCapabilities API (extended through #33803) for mapping merging.
Close #31837 #31611