|
| 1 | +/* |
| 2 | + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one |
| 3 | + * or more contributor license agreements. Licensed under the Elastic License |
| 4 | + * 2.0; you may not use this file except in compliance with the Elastic License |
| 5 | + * 2.0. |
| 6 | + */ |
| 7 | + |
| 8 | +package org.elasticsearch.xpack.sql.qa.single_node; |
| 9 | + |
| 10 | +import org.apache.http.entity.ContentType; |
| 11 | +import org.apache.http.entity.StringEntity; |
| 12 | +import org.elasticsearch.client.Request; |
| 13 | +import org.elasticsearch.xpack.sql.qa.rest.BaseRestSqlTestCase; |
| 14 | + |
| 15 | +import java.io.IOException; |
| 16 | + |
| 17 | +import static org.elasticsearch.xpack.sql.qa.rest.RestSqlTestCase.SQL_QUERY_REST_ENDPOINT; |
| 18 | + |
| 19 | +public class RestSqlDeprecationIT extends BaseRestSqlTestCase { |
| 20 | + |
| 21 | + public void testIndexIncludeParameterIsDeprecated() throws IOException { |
| 22 | + testDeprecationWarning( |
| 23 | + query("SELECT * FROM test").mode(randomMode()).indexIncludeFrozen(randomBoolean()), |
| 24 | + "[index_include_frozen] parameter is deprecated because frozen indices have been deprecated. Consider cold or frozen tiers " |
| 25 | + + "in place of frozen indices." |
| 26 | + ); |
| 27 | + } |
| 28 | + |
| 29 | + public void testIncludeFrozenSyntaxIsDeprecatedInShowTables() throws IOException { |
| 30 | + testFrozenSyntaxIsDeprecated("SHOW TABLES INCLUDE FROZEN", "INCLUDE FROZEN"); |
| 31 | + } |
| 32 | + |
| 33 | + public void testIncludeFrozenSyntaxIsDeprecatedInShowColumns() throws IOException { |
| 34 | + testFrozenSyntaxIsDeprecated("SHOW COLUMNS INCLUDE FROZEN IN test", "INCLUDE FROZEN"); |
| 35 | + } |
| 36 | + |
| 37 | + public void testIncludeFrozenSyntaxIsDeprecatedInDescribeTable() throws IOException { |
| 38 | + testFrozenSyntaxIsDeprecated("DESCRIBE INCLUDE FROZEN test", "INCLUDE FROZEN"); |
| 39 | + } |
| 40 | + |
| 41 | + public void testFrozenSyntaxIsDeprecatedInFromClause() throws IOException { |
| 42 | + testFrozenSyntaxIsDeprecated("SELECT * FROM FROZEN test", "FROZEN"); |
| 43 | + } |
| 44 | + |
| 45 | + private void testFrozenSyntaxIsDeprecated(String query, String syntax) throws IOException { |
| 46 | + testDeprecationWarning( |
| 47 | + query(query).mode(randomMode()), |
| 48 | + "[" |
| 49 | + + syntax |
| 50 | + + "] syntax is deprecated because frozen indices have been deprecated. " |
| 51 | + + "Consider cold or frozen tiers in place of frozen indices." |
| 52 | + ); |
| 53 | + } |
| 54 | + |
| 55 | + private void testDeprecationWarning(RequestObjectBuilder query, String warning) throws IOException { |
| 56 | + index("{\"foo\": 1}"); |
| 57 | + |
| 58 | + Request request = new Request("POST", SQL_QUERY_REST_ENDPOINT); |
| 59 | + request.setEntity(new StringEntity(query.toString(), ContentType.APPLICATION_JSON)); |
| 60 | + request.setOptions(expectWarnings(warning)); |
| 61 | + } |
| 62 | + |
| 63 | +} |
0 commit comments