Skip to content

Commit ad820f6

Browse files
committed
[refactor](lance) Reuse PROPERTIES for index warmup options
1 parent ebb50b0 commit ad820f6

6 files changed

Lines changed: 34 additions & 33 deletions

File tree

‎fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisLexer.g4‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,6 @@ SESSION: 'SESSION';
525525
SESSION_USER: 'SESSION_USER';
526526
SET: 'SET';
527527
SETS: 'SETS';
528-
SETTINGS: 'SETTINGS';
529528
SHAPE: 'SHAPE';
530529
SHOW: 'SHOW';
531530
SIGNED: 'SIGNED';

‎fe/fe-core/src/main/antlr4/org/apache/doris/nereids/DorisParser.g4‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ supportedOtherStatement
545545
properties=propertyClause? #warmUpCluster
546546
| explain? WARM UP SELECT namedExpressionSeq
547547
FROM warmUpSingleTableRef whereClause?
548-
(SETTINGS LEFT_PAREN settings=propertyItemList RIGHT_PAREN)? #warmUpSelect
548+
properties=propertyClause? #warmUpSelect
549549
| BACKUP SNAPSHOT label=multipartIdentifier TO repo=identifier
550550
((ON | EXCLUDE) LEFT_PAREN baseTableRef (COMMA baseTableRef)* RIGHT_PAREN)?
551551
properties=propertyClause? #backup
@@ -2346,7 +2346,6 @@ nonReserved
23462346
| SERIALIZABLE
23472347
| SESSION
23482348
| SESSION_USER
2349-
| SETTINGS
23502349
| SHAPE
23512350
| SKEW
23522351
| SNAPSHOT

‎fe/fe-core/src/main/java/org/apache/doris/nereids/parser/LogicalPlanBuilder.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9610,13 +9610,13 @@ public LogicalPlan visitWarmUpSelect(DorisParser.WarmUpSelectContext ctx) {
96109610
}
96119611

96129612
LogicalProject project = new LogicalProject(projectList, filter);
9613-
Map<String, String> settings = visitPropertyItemList(ctx.settings);
9614-
for (String key : settings.keySet()) {
9613+
Map<String, String> properties = visitPropertyClause(ctx.properties);
9614+
for (String key : properties.keySet()) {
96159615
if (!"read_index_only".equals(key)) {
9616-
throw new AnalysisException("Unknown WARM UP SELECT setting: " + key);
9616+
throw new AnalysisException("Unknown WARM UP SELECT property: " + key);
96179617
}
96189618
}
9619-
String indexOnly = settings.getOrDefault("read_index_only", "false");
9619+
String indexOnly = properties.getOrDefault("read_index_only", "false");
96209620
if (!"true".equalsIgnoreCase(indexOnly) && !"false".equalsIgnoreCase(indexOnly)) {
96219621
throw new AnalysisException("read_index_only must be true or false");
96229622
}

‎fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/WarmupSelectIndexCommandTest.java‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class WarmupSelectIndexCommandTest {
2929
@Test
3030
void reusesWarmupSelectForIndexOnlyMode() {
3131
Assertions.assertInstanceOf(WarmupSelectCommand.class, new NereidsParser().parseSingle(
32-
"WARM UP SELECT * FROM lake.demo.items SETTINGS (\"read_index_only\" = true)"));
32+
"WARM UP SELECT * FROM lake.demo.items PROPERTIES (\"read_index_only\" = true)"));
3333
}
3434

3535
@Test
@@ -40,7 +40,7 @@ void preservesDataModeAndItsFileCacheRequirement() {
4040
try {
4141
Config.cloud_unique_id = "";
4242
context.getSessionVariable().setEnableFileCache(true);
43-
for (String suffix : new String[] {"", " SETTINGS (read_index_only=false)"}) {
43+
for (String suffix : new String[] {"", " PROPERTIES (read_index_only=false)"}) {
4444
WarmupSelectCommand command = (WarmupSelectCommand) new NereidsParser().parseSingle(
4545
"WARM UP SELECT settings FROM items WHERE settings > 0" + suffix);
4646
Assertions.assertEquals(6, command.getResultSetMetaData().getColumns().size());
@@ -49,7 +49,7 @@ void preservesDataModeAndItsFileCacheRequirement() {
4949
Assertions.assertThrows(Exception.class,
5050
() -> new NereidsParser().parseSingle("WARM UP SELECT * FROM items"));
5151
WarmupSelectCommand index = (WarmupSelectCommand) new NereidsParser().parseSingle(
52-
"WARM UP SELECT embedding FROM items SETTINGS (read_index_only=true)");
52+
"WARM UP SELECT embedding FROM items PROPERTIES (read_index_only=true)");
5353
Assertions.assertEquals(5, index.getResultSetMetaData().getColumns().size());
5454
} finally {
5555
Config.cloud_unique_id = cloud;
@@ -62,24 +62,27 @@ void supportsQualifiedColumnsAndStars() {
6262
for (String query : new String[] {
6363
"SELECT i.embedding FROM lake.demo.items i",
6464
"SELECT items.* FROM lake.demo.items",
65-
"SELECT embedding, embedding FROM lake.demo.items"}) {
65+
"SELECT embedding, embedding FROM lake.demo.items",
66+
"SELECT properties FROM lake.demo.items properties",
67+
"SELECT settings FROM lake.demo.items settings"}) {
6668
Assertions.assertInstanceOf(WarmupSelectCommand.class, new NereidsParser().parseSingle(
67-
"WARM UP " + query + " SETTINGS (read_index_only='TRUE')"));
69+
"WARM UP " + query + " PROPERTIES (read_index_only='TRUE')"));
6870
}
6971
}
7072

7173
@Test
72-
void rejectsUnsupportedSettingsAndProjectionSemantics() {
74+
void rejectsUnsupportedPropertiesAndProjectionSemantics() {
7375
for (String sql : new String[] {
7476
"WARM UP INDEX idx ON lake.demo.items",
75-
"WARM UP SELECT * FROM items SETTINGS (read_index_only='yes')",
76-
"WARM UP SELECT * FROM items SETTINGS (typo=true)",
77-
"WARM UP SELECT * FROM items WHERE id=1 SETTINGS (read_index_only=true)",
78-
"EXPLAIN WARM UP SELECT * FROM items SETTINGS (read_index_only=true)",
79-
"WARM UP SELECT wrong.embedding FROM items SETTINGS (read_index_only=true)",
80-
"WARM UP SELECT * EXCEPT(id) FROM items SETTINGS (read_index_only=true)",
81-
"WARM UP SELECT *, id FROM items SETTINGS (read_index_only=true)",
82-
"WARM UP SELECT id+1 FROM items SETTINGS (read_index_only=true)"}) {
77+
"WARM UP SELECT * FROM items SETTINGS (read_index_only=true)",
78+
"WARM UP SELECT * FROM items PROPERTIES (read_index_only='yes')",
79+
"WARM UP SELECT * FROM items PROPERTIES (typo=true)",
80+
"WARM UP SELECT * FROM items WHERE id=1 PROPERTIES (read_index_only=true)",
81+
"EXPLAIN WARM UP SELECT * FROM items PROPERTIES (read_index_only=true)",
82+
"WARM UP SELECT wrong.embedding FROM items PROPERTIES (read_index_only=true)",
83+
"WARM UP SELECT * EXCEPT(id) FROM items PROPERTIES (read_index_only=true)",
84+
"WARM UP SELECT *, id FROM items PROPERTIES (read_index_only=true)",
85+
"WARM UP SELECT id+1 FROM items PROPERTIES (read_index_only=true)"}) {
8386
Assertions.assertThrows(Exception.class, () -> new NereidsParser().parseSingle(sql), sql);
8487
}
8588
}

‎fe/fe-core/src/test/java/org/apache/doris/nereids/trees/plans/commands/WarmupSelectIndexExecutionTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
public class WarmupSelectIndexExecutionTest {
4242
private WarmupSelectCommand command() {
4343
return (WarmupSelectCommand) new NereidsParser().parseSingle(
44-
"WARM UP SELECT * FROM lake.db.items SETTINGS (read_index_only=true)");
44+
"WARM UP SELECT * FROM lake.db.items PROPERTIES (read_index_only=true)");
4545
}
4646

4747
private StmtExecutor executor(ConnectContext context, WarmupSelectCommand command) {
48-
OriginStatement sql = new OriginStatement("WARM UP SELECT * FROM lake.db.items SETTINGS (read_index_only=true)", 0);
48+
OriginStatement sql = new OriginStatement("WARM UP SELECT * FROM lake.db.items PROPERTIES (read_index_only=true)", 0);
4949
LogicalPlanAdapter adapter = new LogicalPlanAdapter(command, new StatementContext(context, sql));
5050
adapter.setOrigStmt(sql);
5151
return new StmtExecutor(context, adapter, true);

‎regression-test/suites/external_table_p0/lance/test_lance_index_prewarm.groovy‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ suite("test_lance_index_prewarm", "p0,external") {
4545
sql "SET enable_file_scanner_v2 = true"
4646
def entries = sql """SELECT IndexName, DatasetVersion FROM lance_index_entries("table"="${tableName}")"""
4747
assertFalse(entries.isEmpty())
48-
String statement = """WARM UP SELECT embedding FROM ${tableName} SETTINGS ("read_index_only" = "true")"""
48+
String statement = """WARM UP SELECT embedding FROM ${tableName} PROPERTIES ("read_index_only" = "true")"""
4949
String query = """
5050
SELECT row_id, _distance FROM vector_search(
5151
"table"="${tableName}", "column"="embedding",
@@ -86,32 +86,32 @@ suite("test_lance_index_prewarm", "p0,external") {
8686
}
8787

8888
// Selecting * must cover every logical index, even if physical segments repeat its name.
89-
def allIndexes = sql """WARM UP SELECT * FROM ${tableName} SETTINGS ("read_index_only" = true)"""
89+
def allIndexes = sql """WARM UP SELECT * FROM ${tableName} PROPERTIES ("read_index_only" = true)"""
9090
assertEquals(entries.collect { it[0] }.toSet(), allIndexes.collect { it[1] }.toSet())
9191
assertEquals(allIndexes.size(), allIndexes.collect { it[1] }.toSet().size())
9292
assertTrue(allIndexes.every { it[2] == warm[0][2] && it[3] == warm[0][3] })
9393
def qualified = sql """WARM UP SELECT t.embedding, t.embedding FROM ${tableName} t
94-
SETTINGS ("read_index_only" = true)"""
94+
PROPERTIES ("read_index_only" = true)"""
9595
assertEquals(1, qualified.size())
9696
assertEquals(indexName, qualified[0][1])
9797
test {
98-
sql """WARM UP SELECT missing_column FROM ${tableName} SETTINGS ("read_index_only" = true)"""
98+
sql """WARM UP SELECT missing_column FROM ${tableName} PROPERTIES ("read_index_only" = true)"""
9999
exception "Unknown or ambiguous index prewarm column"
100100
}
101101
test {
102-
sql """WARM UP SELECT * FROM ${tableName} WHERE row_id = 1 SETTINGS ("read_index_only" = true)"""
102+
sql """WARM UP SELECT * FROM ${tableName} WHERE row_id = 1 PROPERTIES ("read_index_only" = true)"""
103103
exception "does not support WHERE or EXPLAIN"
104104
}
105105
test {
106-
sql """WARM UP SELECT * FROM ${tableName} SETTINGS ("read_index_only" = "invalid")"""
106+
sql """WARM UP SELECT * FROM ${tableName} PROPERTIES ("read_index_only" = "invalid")"""
107107
exception "read_index_only must be true or false"
108108
}
109109
test {
110-
sql """WARM UP SELECT * FROM ${tableName} SETTINGS ("unknown_option" = true)"""
111-
exception "Unknown WARM UP SELECT setting"
110+
sql """WARM UP SELECT * FROM ${tableName} PROPERTIES ("unknown_option" = true)"""
111+
exception "Unknown WARM UP SELECT property"
112112
}
113113
test {
114-
sql """WARM UP SELECT * FROM internal.information_schema.tables SETTINGS ("read_index_only" = true)"""
114+
sql """WARM UP SELECT * FROM internal.information_schema.tables PROPERTIES ("read_index_only" = true)"""
115115
exception "requires a Lance catalog table"
116116
}
117117
// Index mode uses the SDK cache independently of the data-file-cache session switch.
@@ -129,7 +129,7 @@ suite("test_lance_index_prewarm", "p0,external") {
129129
}
130130
sql "SET ${cacheVariable} = ${isCloudMode() ? 'false' : 'true'}"
131131
try {
132-
for (String suffix : ["", ' SETTINGS ("read_index_only" = false)']) {
132+
for (String suffix : ["", ' PROPERTIES ("read_index_only" = false)']) {
133133
def dataWarm = sql "WARM UP SELECT row_id FROM ${tableName} WHERE row_id >= 0${suffix}"
134134
assertTrue(dataWarm.every { it.size() == 6 })
135135
assertEquals("TOTAL", dataWarm[-1][0])

0 commit comments

Comments
 (0)