-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QL: add unsigned_long type support (#65145)
This introduces the UNSIGNED_LONG type to QL following its availability in ES (#60050). The type is mapped to a BigInteger whose value is checked against the UL bounds. The SQL will now support the type as literal and in the arithmetic functions; the non-arithmetic functions however are unchanged (i.e. they still require a long / int parameter where that is the case). The type is version-gated: for the driver SQL clients (only) the server checks their version and in case this is lower than the one introducing the UL support, it fails the request, for queries, or simply hidden in catalog functions (similar to how UNSUPPORTED is currently treated in the similar case) The JDBC tests are adjusted to read the (bwc) version of the driver they are run against and selectively disable part of the tests accordingly. Closes #63312
- Loading branch information
Showing
82 changed files
with
3,488 additions
and
868 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pr: 65145 | ||
summary: Add `unsigned_long` type support | ||
area: Query Languages | ||
type: enhancement | ||
issues: | ||
- 63312 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/IndexCompatibility.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ql.index; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.xpack.ql.type.DataType; | ||
import org.elasticsearch.xpack.ql.type.EsField; | ||
import org.elasticsearch.xpack.ql.type.UnsupportedEsField; | ||
|
||
import java.util.Map; | ||
|
||
import static org.elasticsearch.xpack.ql.index.VersionCompatibilityChecks.isTypeSupportedInVersion; | ||
import static org.elasticsearch.xpack.ql.type.DataTypes.isPrimitive; | ||
import static org.elasticsearch.xpack.ql.type.Types.propagateUnsupportedType; | ||
|
||
public final class IndexCompatibility { | ||
|
||
public static Map<String, EsField> compatible(Map<String, EsField> mapping, Version version) { | ||
for (Map.Entry<String, EsField> entry : mapping.entrySet()) { | ||
EsField esField = entry.getValue(); | ||
DataType dataType = esField.getDataType(); | ||
if (isPrimitive(dataType) == false) { | ||
compatible(esField.getProperties(), version); | ||
} else if (isTypeSupportedInVersion(dataType, version) == false) { | ||
EsField field = new UnsupportedEsField(entry.getKey(), dataType.name(), null, esField.getProperties()); | ||
entry.setValue(field); | ||
propagateUnsupportedType(entry.getKey(), dataType.name(), esField.getProperties()); | ||
} | ||
} | ||
return mapping; | ||
} | ||
|
||
public static EsIndex compatible(EsIndex esIndex, Version version) { | ||
compatible(esIndex.mapping(), version); | ||
return esIndex; | ||
} | ||
|
||
public static IndexResolution compatible(IndexResolution indexResolution, Version version) { | ||
if (indexResolution.isValid()) { | ||
compatible(indexResolution.get(), version); | ||
} | ||
return indexResolution; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
.../plugin/ql/src/main/java/org/elasticsearch/xpack/ql/index/VersionCompatibilityChecks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.ql.index; | ||
|
||
import org.elasticsearch.Version; | ||
import org.elasticsearch.core.Nullable; | ||
import org.elasticsearch.xpack.ql.type.DataType; | ||
|
||
import static org.elasticsearch.Version.V_8_2_0; | ||
import static org.elasticsearch.xpack.ql.type.DataTypes.UNSIGNED_LONG; | ||
|
||
public final class VersionCompatibilityChecks { | ||
|
||
public static final Version INTRODUCING_UNSIGNED_LONG = V_8_2_0; | ||
|
||
private VersionCompatibilityChecks() {} | ||
|
||
public static boolean isTypeSupportedInVersion(DataType dataType, Version version) { | ||
if (dataType == UNSIGNED_LONG) { | ||
return supportsUnsignedLong(version); | ||
} | ||
return true; | ||
} | ||
|
||
/** | ||
* Does the provided {@code version} support the unsigned_long type (PR#60050)? | ||
*/ | ||
public static boolean supportsUnsignedLong(Version version) { | ||
return INTRODUCING_UNSIGNED_LONG.compareTo(version) <= 0; | ||
} | ||
|
||
public static @Nullable Version versionIntroducingType(DataType dataType) { | ||
if (dataType == UNSIGNED_LONG) { | ||
return INTRODUCING_UNSIGNED_LONG; | ||
} | ||
|
||
return null; | ||
} | ||
} |
Oops, something went wrong.