-
Notifications
You must be signed in to change notification settings - Fork 25.2k
SQL: Deprecate index_include_frozen request parameter and FROZEN
keyword
#83943
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 10 commits
1b2ebd9
2f50d4e
f74839f
854cefd
a19741a
5afb9f6
c4219fb
b743efc
f2e567e
7d5a577
7f946e2
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pr: 83943 | ||
summary: Deprecate `index_include_frozen` request parameter | ||
area: SQL | ||
type: deprecation | ||
issues: | ||
- 81939 | ||
deprecation: | ||
title: Deprecate `index_include_frozen` request parameter in `_sql` API | ||
area: REST API | ||
details: |- | ||
Following the deprecation of frozen indices, the `index_include_frozen` | ||
parameter and `FROZEN` syntax is now also deprecated. | ||
impact: |- | ||
You should unfreeze frozen indices using the | ||
{ref}/unfreeze-index-api.html[unfreeze index API] and stop using the | ||
`index_include_frozen` parameter or the `FROZEN` keyword in SQL | ||
queries. For some use cases, the frozen tier may be a suitable | ||
replacement for frozen indices. See {ref}/data-tiers.html[data tiers] | ||
for more information. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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.sql.qa.single_node; | ||
|
||
import org.elasticsearch.xpack.sql.qa.jdbc.JdbcIntegrationTestCase; | ||
|
||
import java.sql.Connection; | ||
import java.sql.ResultSet; | ||
import java.sql.Statement; | ||
|
||
public class JdbcWarningsIT extends JdbcIntegrationTestCase { | ||
|
||
public void testDeprecationWarningsDoNotReachJdbcDriver() throws Exception { | ||
index("test_data", b -> b.field("foo", 1)); | ||
|
||
try (Connection connection = esJdbc(); Statement statement = connection.createStatement()) { | ||
ResultSet rs = statement.executeQuery("SELECT * FROM FROZEN \"test_*\""); | ||
assertNull(rs.getWarnings()); | ||
} | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* 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.sql.qa.single_node; | ||
|
||
import org.apache.http.entity.ContentType; | ||
import org.apache.http.entity.StringEntity; | ||
import org.elasticsearch.client.Request; | ||
import org.elasticsearch.xpack.sql.qa.rest.BaseRestSqlTestCase; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.elasticsearch.xpack.sql.qa.rest.RestSqlTestCase.SQL_QUERY_REST_ENDPOINT; | ||
|
||
public class RestSqlDeprecationIT extends BaseRestSqlTestCase { | ||
|
||
public void testIndexIncludeParameterIsDeprecated() throws IOException { | ||
testDeprecationWarning( | ||
query("SELECT * FROM test").mode(randomMode()).indexIncludeFrozen(randomBoolean()), | ||
"[index_include_frozen] parameter is deprecated because frozen indices have been deprecated. Consider cold or frozen tiers " | ||
+ "in place of frozen indices." | ||
); | ||
} | ||
|
||
public void testIncludeFrozenSyntaxIsDeprecatedInShowTables() throws IOException { | ||
testFrozenSyntaxIsDeprecated("SHOW TABLES INCLUDE FROZEN", "INCLUDE FROZEN"); | ||
} | ||
|
||
public void testIncludeFrozenSyntaxIsDeprecatedInShowColumns() throws IOException { | ||
testFrozenSyntaxIsDeprecated("SHOW COLUMNS INCLUDE FROZEN IN test", "INCLUDE FROZEN"); | ||
} | ||
|
||
public void testIncludeFrozenSyntaxIsDeprecatedInDescribeTable() throws IOException { | ||
testFrozenSyntaxIsDeprecated("DESCRIBE INCLUDE FROZEN test", "INCLUDE FROZEN"); | ||
} | ||
|
||
public void testFrozenSyntaxIsDeprecatedInFromClause() throws IOException { | ||
testFrozenSyntaxIsDeprecated("SELECT * FROM FROZEN test", "FROZEN"); | ||
} | ||
|
||
public void testFrozenSyntaxIsDeprecated(String query, String syntax) throws IOException { | ||
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.
|
||
testDeprecationWarning( | ||
query(query).mode(randomMode()), | ||
"[" | ||
+ syntax | ||
+ "] syntax is deprecated because frozen indices have been deprecated. " | ||
+ "Consider cold or frozen tiers in place of frozen indices." | ||
); | ||
} | ||
|
||
public void testDeprecationWarning(RequestObjectBuilder query, String warning) throws IOException { | ||
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.
|
||
index("{\"foo\": 1}"); | ||
|
||
Request request = new Request("POST", SQL_QUERY_REST_ENDPOINT); | ||
request.setEntity(new StringEntity(query.toString(), ContentType.APPLICATION_JSON)); | ||
request.setOptions(expectWarnings(warning)); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,8 @@ | |
import org.antlr.v4.runtime.ParserRuleContext; | ||
import org.antlr.v4.runtime.Token; | ||
import org.antlr.v4.runtime.tree.TerminalNode; | ||
import org.elasticsearch.common.logging.DeprecationCategory; | ||
import org.elasticsearch.common.logging.DeprecationLogger; | ||
import org.elasticsearch.common.util.Maps; | ||
import org.elasticsearch.xpack.ql.expression.Alias; | ||
import org.elasticsearch.xpack.ql.expression.Expression; | ||
|
@@ -63,11 +65,23 @@ | |
import java.util.Map; | ||
|
||
import static java.util.Collections.emptyList; | ||
import static org.elasticsearch.common.logging.LoggerMessageFormat.format; | ||
import static org.elasticsearch.xpack.ql.parser.ParserUtils.source; | ||
import static org.elasticsearch.xpack.ql.parser.ParserUtils.visitList; | ||
|
||
abstract class LogicalPlanBuilder extends ExpressionBuilder { | ||
|
||
private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(CommandBuilder.class); | ||
|
||
private static final String FROZEN_DEPRECATION_WARNING = "[{}] syntax is deprecated because frozen indices have been deprecated. " | ||
+ "Consider cold or frozen tiers in place of frozen indices."; | ||
|
||
protected void warnDeprecatedFrozenSyntax(boolean includeFrozen, String syntax) { | ||
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. A better name for this method is |
||
if (includeFrozen) { | ||
DEPRECATION_LOGGER.warn(DeprecationCategory.PARSING, "include_frozen_syntax", format(null, FROZEN_DEPRECATION_WARNING, syntax)); | ||
} | ||
} | ||
|
||
protected LogicalPlanBuilder(Map<Token, SqlTypedParamValue> params, ZoneId zoneId) { | ||
super(params, zoneId); | ||
} | ||
|
@@ -267,7 +281,9 @@ public Object visitSubquery(SubqueryContext ctx) { | |
public LogicalPlan visitTableName(TableNameContext ctx) { | ||
String alias = visitQualifiedName(ctx.qualifiedName()); | ||
TableIdentifier tableIdentifier = visitTableIdentifier(ctx.tableIdentifier()); | ||
return new UnresolvedRelation(source(ctx), tableIdentifier, alias, ctx.FROZEN() != null); | ||
boolean includeFrozen = ctx.FROZEN() != null; | ||
warnDeprecatedFrozenSyntax(includeFrozen, "FROZEN"); | ||
return new UnresolvedRelation(source(ctx), tableIdentifier, alias, includeFrozen); | ||
} | ||
|
||
private Limit limit(LogicalPlan plan, Source source, Token limit) { | ||
|
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.
Any reason for having this test only in
single_node
scenario? With regards tomulti_node
it's probably not worth considering it, but how about thesecurity
tests suite?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 also saw that this test is better put to the JDBC test cases in
org.elasticsearch.xpack.sql.qa.jdbc
instead oforg.elasticsearch.xpack.sql.qa