Skip to content

Commit 1d5c842

Browse files
committed
SQL: Fix column size for IP data type (#53056)
Set size/displaySize to 45 which is the maximum string for an IP (v6), since IPs are returned as strings. Fixes: #52762 (cherry picked from commit 815f017)
1 parent 4b528d9 commit 1d5c842

File tree

4 files changed

+61
-99
lines changed

4 files changed

+61
-99
lines changed

x-pack/plugin/ql/src/main/java/org/elasticsearch/xpack/ql/type/DataTypes.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public final class DataTypes {
4141
// date
4242
public static final DataType DATETIME = new DataType("DATETIME", "date", Long.BYTES, false, false, true);
4343
// ip
44-
public static final DataType IP = new DataType("ip", 39, false, false, true);
44+
public static final DataType IP = new DataType("ip", 45, false, false, true);
4545
// binary
4646
public static final DataType BINARY = new DataType("binary", Integer.MAX_VALUE, false, false, true);
4747
// complex types
@@ -164,4 +164,4 @@ public static boolean areCompatible(DataType left, DataType right) {
164164
|| (left == DATETIME && right == DATETIME);
165165
}
166166
}
167-
}
167+
}

x-pack/plugin/sql/qa/src/main/java/org/elasticsearch/xpack/sql/qa/SqlProtocolTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ public void testDateTimes() throws IOException {
8787
}
8888

8989
public void testIPs() throws IOException {
90-
assertQuery("SELECT CAST('12.13.14.15' AS IP)", "CAST('12.13.14.15' AS IP)", "ip", "12.13.14.15", 0);
90+
assertQuery("SELECT CAST('12.13.14.15' AS IP)", "CAST('12.13.14.15' AS IP)", "ip", "12.13.14.15", 45);
9191
assertQuery("SELECT CAST('2001:0db8:0000:0000:0000:ff00:0042:8329' AS IP)", "CAST('2001:0db8:0000:0000:0000:ff00:0042:8329' AS IP)",
92-
"ip", "2001:0db8:0000:0000:0000:ff00:0042:8329", 0);
92+
"ip", "2001:0db8:0000:0000:0000:ff00:0042:8329", 45);
9393
}
9494

9595
public void testDateTimeIntervals() throws IOException {

0 commit comments

Comments
 (0)