diff --git a/x-pack/plugin/sql/qa/src/main/resources/alias.csv-spec b/x-pack/plugin/sql/qa/src/main/resources/alias.csv-spec index fe8e6e5da4e..d395ec2b21b 100644 --- a/x-pack/plugin/sql/qa/src/main/resources/alias.csv-spec +++ b/x-pack/plugin/sql/qa/src/main/resources/alias.csv-spec @@ -84,7 +84,7 @@ SHOW TABLES LIKE 'test\_alias' ESCAPE '\'; name:s | type:s -test_alias | ALIAS +test_alias | VIEW ; showPattern @@ -92,8 +92,8 @@ SHOW TABLES LIKE 'test_%'; name:s | type:s -test_alias | ALIAS -test_alias_emp | ALIAS +test_alias | VIEW +test_alias_emp | VIEW test_emp | BASE TABLE test_emp_copy | BASE TABLE ; diff --git a/x-pack/plugin/sql/qa/src/main/resources/command-sys.csv-spec b/x-pack/plugin/sql/qa/src/main/resources/command-sys.csv-spec index 38f3772f76c..2ed05aadb6c 100644 --- a/x-pack/plugin/sql/qa/src/main/resources/command-sys.csv-spec +++ b/x-pack/plugin/sql/qa/src/main/resources/command-sys.csv-spec @@ -7,5 +7,5 @@ SYS TABLE TYPES; TABLE_TYPE:s BASE TABLE -ALIAS +VIEW ; diff --git a/x-pack/plugin/sql/qa/src/main/resources/command.csv-spec b/x-pack/plugin/sql/qa/src/main/resources/command.csv-spec index c52a5f807bd..ef8606bbed0 100644 --- a/x-pack/plugin/sql/qa/src/main/resources/command.csv-spec +++ b/x-pack/plugin/sql/qa/src/main/resources/command.csv-spec @@ -178,8 +178,8 @@ SHOW TABLES; name | type logs |BASE TABLE -test_alias |ALIAS -test_alias_emp |ALIAS +test_alias |VIEW +test_alias_emp |VIEW test_emp |BASE TABLE test_emp_copy |BASE TABLE ; @@ -217,8 +217,8 @@ showTablesIdentifierPatternOnAliases SHOW TABLES "test*,-test_emp*"; name:s | type:s -test_alias |ALIAS -test_alias_emp |ALIAS +test_alias |VIEW +test_alias_emp |VIEW ; // DESCRIBE diff --git a/x-pack/plugin/sql/qa/src/main/resources/docs.csv-spec b/x-pack/plugin/sql/qa/src/main/resources/docs.csv-spec index e6bde4795a8..132b89ae1b7 100644 --- a/x-pack/plugin/sql/qa/src/main/resources/docs.csv-spec +++ b/x-pack/plugin/sql/qa/src/main/resources/docs.csv-spec @@ -96,7 +96,7 @@ SHOW TABLES; name | type ---------------+--------------- emp |BASE TABLE -employees |ALIAS +employees |VIEW library |BASE TABLE // end::showTables @@ -120,7 +120,7 @@ SHOW TABLES LIKE 'emp%'; name | type ---------------+--------------- emp |BASE TABLE -employees |ALIAS +employees |VIEW // end::showTablesLikeWildcard ; @@ -167,7 +167,7 @@ SHOW TABLES "*,-l*"; name | type ---------------+--------------- emp |BASE TABLE -employees |ALIAS +employees |VIEW // end::showTablesEsMultiIndex ; diff --git a/x-pack/plugin/sql/qa/src/main/resources/setup_mock_metadata_get_table_types.sql b/x-pack/plugin/sql/qa/src/main/resources/setup_mock_metadata_get_table_types.sql index 52c767cb734..76dd3bebf61 100644 --- a/x-pack/plugin/sql/qa/src/main/resources/setup_mock_metadata_get_table_types.sql +++ b/x-pack/plugin/sql/qa/src/main/resources/setup_mock_metadata_get_table_types.sql @@ -1,7 +1,7 @@ CREATE TABLE mock ( TABLE_TYPE VARCHAR, ) AS -SELECT 'ALIAS' FROM DUAL -UNION ALL SELECT 'BASE TABLE' FROM DUAL +UNION ALL +SELECT 'VIEW' FROM DUAL ; diff --git a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java index b3fdb4d1170..618dd66d88d 100644 --- a/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java +++ b/x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/analysis/index/IndexResolver.java @@ -61,7 +61,7 @@ public class IndexResolver { public enum IndexType { INDEX("BASE TABLE"), - ALIAS("ALIAS"), + ALIAS("VIEW"), // value for user types unrecognized UNKNOWN("UNKNOWN"); diff --git a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/command/sys/SysTablesTests.java b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/command/sys/SysTablesTests.java index aae5ac06447..257c6733805 100644 --- a/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/command/sys/SysTablesTests.java +++ b/x-pack/plugin/sql/src/test/java/org/elasticsearch/xpack/sql/plan/logical/command/sys/SysTablesTests.java @@ -61,9 +61,9 @@ public class SysTablesTests extends ESTestCase { public void testSysTablesEnumerateTypes() throws Exception { executeCommand("SYS TABLES TYPE '%'", r -> { assertEquals(2, r.size()); - assertEquals("ALIAS", r.column(3)); - assertTrue(r.advanceRow()); assertEquals("BASE TABLE", r.column(3)); + assertTrue(r.advanceRow()); + assertEquals("VIEW", r.column(3)); }); } @@ -77,28 +77,28 @@ public class SysTablesTests extends ESTestCase { public void testSysTablesNoTypes() throws Exception { executeCommand("SYS TABLES", r -> { assertEquals(2, r.size()); - assertEquals("ALIAS", r.column(3)); - assertTrue(r.advanceRow()); assertEquals("BASE TABLE", r.column(3)); + assertTrue(r.advanceRow()); + assertEquals("VIEW", r.column(3)); }, index, alias); } public void testSysTablesPattern() throws Exception { executeCommand("SYS TABLES LIKE '%'", r -> { - assertEquals("alias", r.column(2)); + assertEquals("test", r.column(2)); assertTrue(r.advanceRow()); assertEquals(2, r.size()); - assertEquals("test", r.column(2)); + assertEquals("alias", r.column(2)); }, index, alias); } public void testSysTablesPatternParameterized() throws Exception { List params = asList(param("%")); executeCommand("SYS TABLES LIKE ?", params, r -> { - assertEquals("alias", r.column(2)); + assertEquals("test", r.column(2)); assertTrue(r.advanceRow()); assertEquals(2, r.size()); - assertEquals("test", r.column(2)); + assertEquals("alias", r.column(2)); }, alias, index); } @@ -149,38 +149,38 @@ public class SysTablesTests extends ESTestCase { } public void testSysTablesOnlyIndicesAndAliases() throws Exception { - executeCommand("SYS TABLES LIKE 'test' TYPE 'ALIAS', 'BASE TABLE'", r -> { - assertEquals("alias", r.column(2)); - assertTrue(r.advanceRow()); + executeCommand("SYS TABLES LIKE 'test' TYPE 'VIEW', 'BASE TABLE'", r -> { assertEquals(2, r.size()); assertEquals("test", r.column(2)); + assertTrue(r.advanceRow()); + assertEquals("alias", r.column(2)); }, index, alias); } public void testSysTablesOnlyIndicesAndAliasesParameterized() throws Exception { - List params = asList(param("ALIAS"), param("BASE TABLE")); + List params = asList(param("VIEW"), param("BASE TABLE")); executeCommand("SYS TABLES LIKE 'test' TYPE ?, ?", params, r -> { - assertEquals("alias", r.column(2)); - assertTrue(r.advanceRow()); assertEquals(2, r.size()); assertEquals("test", r.column(2)); + assertTrue(r.advanceRow()); + assertEquals("alias", r.column(2)); }, index, alias); } public void testSysTablesOnlyIndicesLegacyAndAliasesParameterized() throws Exception { - List params = asList(param("ALIAS"), param("TABLE")); + List params = asList(param("VIEW"), param("TABLE")); executeCommand("SYS TABLES LIKE 'test' TYPE ?, ?", params, r -> { - assertEquals("alias", r.column(2)); - assertEquals("ALIAS", r.column(3)); - assertTrue(r.advanceRow()); assertEquals(2, r.size()); assertEquals("test", r.column(2)); assertEquals("TABLE", r.column(3)); + assertTrue(r.advanceRow()); + assertEquals("alias", r.column(2)); + assertEquals("VIEW", r.column(3)); }, index, alias); } public void testSysTablesWithCatalogOnlyAliases() throws Exception { - executeCommand("SYS TABLES CATALOG LIKE '%' LIKE 'test' TYPE 'ALIAS'", r -> { + executeCommand("SYS TABLES CATALOG LIKE '%' LIKE 'test' TYPE 'VIEW'", r -> { assertEquals(1, r.size()); assertEquals("alias", r.column(2)); }, alias);