diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java index bf43d39d573b3..af49010698add 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java @@ -188,8 +188,8 @@ public void renameTable(String dbName, String tblName, String newTblName) throws } @Override - public boolean createView(ConnectorViewDefinition connectorViewDefinition, boolean replace) { - return delegate.createView(connectorViewDefinition, replace); + public boolean createView(String catalogName, ConnectorViewDefinition connectorViewDefinition, boolean replace) { + return delegate.createView(catalogName, connectorViewDefinition, replace); } @Override diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergApiConverter.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergApiConverter.java index 782fd8dfa4a42..57c53eda3f6f1 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergApiConverter.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergApiConverter.java @@ -14,6 +14,7 @@ package com.starrocks.connector.iceberg; +import com.google.common.base.Strings; import com.google.common.collect.Lists; import com.starrocks.catalog.ArrayType; import com.starrocks.catalog.Column; @@ -25,8 +26,11 @@ import com.starrocks.catalog.StructField; import com.starrocks.catalog.StructType; import com.starrocks.catalog.Type; +import com.starrocks.connector.ConnectorViewDefinition; import com.starrocks.connector.exception.StarRocksConnectorException; import com.starrocks.connector.hive.RemoteFileInputFormat; +import com.starrocks.qe.ConnectContext; +import com.starrocks.server.GlobalStateMgr; import com.starrocks.thrift.TIcebergColumnStats; import com.starrocks.thrift.TIcebergDataFile; import com.starrocks.thrift.TIcebergSchema; @@ -425,4 +429,24 @@ public static List getPartitionColumns(List fields, public static Namespace convertDbNameToNamespace(String dbName) { return Namespace.of(dbName.split("\\.")); } + + public static Map buildViewProperties(ConnectorViewDefinition definition, String catalogName) { + ConnectContext connectContext = ConnectContext.get(); + if (connectContext == null) { + throw new StarRocksConnectorException("not found connect context when building iceberg view properties"); + } + + String queryId = connectContext.getQueryId().toString(); + + Map properties = com.google.common.collect.ImmutableMap.of( + "queryId", queryId, + "starrocksCatalog", catalogName, + "starrocksVersion", GlobalStateMgr.getCurrentState().getNodeMgr().getMySelf().getFeVersion()); + + if (!Strings.isNullOrEmpty(definition.getComment())) { + properties.put(IcebergMetadata.COMMENT, definition.getComment()); + } + + return properties; + } } \ No newline at end of file diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergCatalog.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergCatalog.java index 36914a90d665e..24760cb327993 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergCatalog.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergCatalog.java @@ -26,6 +26,7 @@ import com.starrocks.connector.exception.StarRocksConnectorException; import com.starrocks.memory.MemoryTrackable; import org.apache.iceberg.FileScanTask; +import org.apache.iceberg.MetadataTableType; import org.apache.iceberg.MetadataTableUtils; import org.apache.iceberg.PartitionSpec; import org.apache.iceberg.PartitionsTable; @@ -35,10 +36,12 @@ import org.apache.iceberg.Table; import org.apache.iceberg.TableScan; import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; import org.apache.iceberg.exceptions.NoSuchTableException; import org.apache.iceberg.io.CloseableIterable; import org.apache.iceberg.util.StructProjection; import org.apache.iceberg.view.View; +import org.apache.iceberg.view.ViewBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -49,6 +52,10 @@ import java.util.Map; import java.util.concurrent.ExecutorService; +import static com.google.common.base.Preconditions.checkArgument; +import static com.starrocks.connector.iceberg.IcebergApiConverter.buildViewProperties; +import static com.starrocks.connector.iceberg.IcebergApiConverter.convertDbNameToNamespace; +import static com.starrocks.connector.iceberg.IcebergMetadata.LOCATION_PROPERTY; import static org.apache.iceberg.StarRocksIcebergTableScan.newTableScanContext; public interface IcebergCatalog extends MemoryTrackable { @@ -99,7 +106,31 @@ default boolean tableExists(String dbName, String tableName) throws StarRocksCon } } - default boolean createView(ConnectorViewDefinition connectorViewDefinition, boolean replace) { + default boolean createView(String catalogName, ConnectorViewDefinition connectorViewDefinition, boolean replace) { + return createViewDefault(connectorViewDefinition.getDatabaseName(), connectorViewDefinition, replace); + } + + default boolean createViewDefault(String catalogName, ConnectorViewDefinition definition, boolean replace) { + Schema schema = IcebergApiConverter.toIcebergApiSchema(definition.getColumns()); + Namespace ns = convertDbNameToNamespace(definition.getDatabaseName()); + ViewBuilder viewBuilder = getViewBuilder(TableIdentifier.of(ns, definition.getViewName())); + viewBuilder = viewBuilder.withSchema(schema) + .withQuery("starrocks", definition.getInlineViewDef()) + .withDefaultNamespace(ns) + .withDefaultCatalog(definition.getCatalogName()) + .withProperties(buildViewProperties(definition, catalogName)) + .withLocation(defaultTableLocation(ns, definition.getViewName())); + + if (replace) { + viewBuilder.createOrReplace(); + } else { + viewBuilder.create(); + } + + return true; + } + + default ViewBuilder getViewBuilder(TableIdentifier identifier) { throw new StarRocksConnectorException("This catalog doesn't support creating views"); } @@ -132,10 +163,18 @@ default StarRocksIcebergTableScan getTableScan(Table table, StarRocksIcebergTabl } default String defaultTableLocation(Namespace ns, String tableName) { - return ""; + Map properties = loadNamespaceMetadata(ns); + String databaseLocation = properties.get(LOCATION_PROPERTY); + checkArgument(databaseLocation != null, "location must be set for %s.%s", ns, tableName); + + if (databaseLocation.endsWith("/")) { + return databaseLocation + tableName; + } else { + return databaseLocation + "/" + tableName; + } } - default Map loadNamespaceMetadata(Namespace ns) { + default Map loadNamespaceMetadata(Namespace ns) { return new HashMap<>(); } @@ -152,7 +191,7 @@ default Map getPartitions(IcebergTable icebergTable, long sna Table nativeTable = icebergTable.getNativeTable(); Map partitionMap = Maps.newHashMap(); PartitionsTable partitionsTable = (PartitionsTable) MetadataTableUtils. - createMetadataTableInstance(nativeTable, org.apache.iceberg.MetadataTableType.PARTITIONS); + createMetadataTableInstance(nativeTable, MetadataTableType.PARTITIONS); TableScan tableScan = partitionsTable.newScan(); if (snapshotId != -1) { tableScan = tableScan.useSnapshot(snapshotId); diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergMetadata.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergMetadata.java index 1b51583a0d9f4..8de8358e05dfd 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergMetadata.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergMetadata.java @@ -306,7 +306,7 @@ public void createView(CreateViewStmt stmt) throws DdlException { } ConnectorViewDefinition viewDefinition = ConnectorViewDefinition.fromCreateViewStmt(stmt); - icebergCatalog.createView(viewDefinition, stmt.isReplace()); + icebergCatalog.createView(catalogName, viewDefinition, stmt.isReplace()); } @Override diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/hive/IcebergHiveCatalog.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/hive/IcebergHiveCatalog.java index a2942e7e59815..9f5a27c4a7add 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/hive/IcebergHiveCatalog.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/hive/IcebergHiveCatalog.java @@ -17,6 +17,7 @@ import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Preconditions; import com.google.common.base.Strings; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; import com.starrocks.catalog.Database; import com.starrocks.common.Config; @@ -41,6 +42,8 @@ import org.apache.iceberg.catalog.Namespace; import org.apache.iceberg.catalog.TableIdentifier; import org.apache.iceberg.hive.HiveCatalog; +import org.apache.iceberg.view.View; +import org.apache.iceberg.view.ViewBuilder; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -52,6 +55,7 @@ import java.util.stream.Collectors; import static com.starrocks.connector.ConnectorTableId.CONNECTOR_ID_GENERATOR; +import static com.starrocks.connector.iceberg.IcebergApiConverter.convertDbNameToNamespace; import static com.starrocks.connector.iceberg.IcebergCatalogProperties.HIVE_METASTORE_TIMEOUT; import static com.starrocks.connector.iceberg.IcebergCatalogProperties.HIVE_METASTORE_URIS; import static com.starrocks.connector.iceberg.IcebergCatalogProperties.ICEBERG_METASTORE_URIS; @@ -93,6 +97,12 @@ public IcebergHiveCatalog(String name, Configuration conf, Map p delegate = (HiveCatalog) CatalogUtil.loadCatalog(HiveCatalog.class.getName(), name, copiedProperties, conf); } + @VisibleForTesting + public IcebergHiveCatalog(HiveCatalog hiveCatalog, Configuration conf) { + this.delegate = hiveCatalog; + this.conf = conf; + } + @Override public IcebergCatalogType getIcebergCatalogType() { return IcebergCatalogType.HIVE_CATALOG; @@ -201,6 +211,26 @@ public void renameTable(String dbName, String tblName, String newTblName) throws delegate.renameTable(TableIdentifier.of(dbName, tblName), TableIdentifier.of(dbName, newTblName)); } + @Override + public ViewBuilder getViewBuilder(TableIdentifier identifier) { + return delegate.buildView(identifier); + } + + @Override + public boolean dropView(String dbName, String viewName) { + return delegate.dropView(TableIdentifier.of(convertDbNameToNamespace(dbName), viewName)); + } + + @Override + public View getView(String dbName, String viewName) { + return delegate.loadView(TableIdentifier.of(convertDbNameToNamespace(dbName), viewName)); + } + + @Override + public Map loadNamespaceMetadata(Namespace ns) { + return ImmutableMap.copyOf(delegate.loadNamespaceMetadata(ns)); + } + @Override public void deleteUncommittedDataFiles(List fileLocations) { if (fileLocations.isEmpty()) { diff --git a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/rest/IcebergRESTCatalog.java b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/rest/IcebergRESTCatalog.java index dacdc451aeb68..c81eac5af0b1f 100644 --- a/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/rest/IcebergRESTCatalog.java +++ b/fe/fe-core/src/main/java/com/starrocks/connector/iceberg/rest/IcebergRESTCatalog.java @@ -21,7 +21,6 @@ import com.starrocks.common.MetaNotFoundException; import com.starrocks.connector.ConnectorViewDefinition; import com.starrocks.connector.exception.StarRocksConnectorException; -import com.starrocks.connector.iceberg.IcebergApiConverter; import com.starrocks.connector.iceberg.IcebergCatalog; import com.starrocks.connector.iceberg.IcebergCatalogType; import com.starrocks.connector.iceberg.cost.IcebergMetricsReporter; @@ -54,7 +53,6 @@ import java.util.Map; import java.util.stream.Collectors; -import static com.google.common.base.Preconditions.checkArgument; import static com.starrocks.connector.ConnectorTableId.CONNECTOR_ID_GENERATOR; import static com.starrocks.connector.iceberg.IcebergApiConverter.convertDbNameToNamespace; import static com.starrocks.connector.iceberg.IcebergCatalogProperties.ICEBERG_CUSTOM_PROPERTIES_PREFIX; @@ -226,24 +224,8 @@ public void renameTable(String dbName, String tblName, String newTblName) throws } @Override - public boolean createView(ConnectorViewDefinition definition, boolean replace) { - Schema schema = IcebergApiConverter.toIcebergApiSchema(definition.getColumns()); - Namespace ns = convertDbNameToNamespace(definition.getDatabaseName()); - ViewBuilder viewBuilder = delegate.buildView(TableIdentifier.of(ns, definition.getViewName())); - viewBuilder = viewBuilder.withSchema(schema) - .withQuery("starrocks", definition.getInlineViewDef()) - .withDefaultNamespace(ns) - .withDefaultCatalog(definition.getCatalogName()) - .withProperties(buildProperties(definition)) - .withLocation(defaultTableLocation(ns, definition.getViewName())); - - if (replace) { - viewBuilder.createOrReplace(); - } else { - viewBuilder.create(); - } - - return true; + public ViewBuilder getViewBuilder(TableIdentifier identifier) { + return delegate.buildView(identifier); } @Override @@ -279,20 +261,7 @@ public String toString() { } @Override - public String defaultTableLocation(Namespace ns, String tableName) { - Map properties = delegate.loadNamespaceMetadata(ns); - String databaseLocation = properties.get(LOCATION_PROPERTY); - checkArgument(databaseLocation != null, "location must be set for %s.%s", ns, tableName); - - if (databaseLocation.endsWith("/")) { - return databaseLocation + tableName; - } else { - return databaseLocation + "/" + tableName; - } - } - - @Override - public Map loadNamespaceMetadata(Namespace ns) { + public Map loadNamespaceMetadata(Namespace ns) { return ImmutableMap.copyOf(delegate.loadNamespaceMetadata(ns)); } diff --git a/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergHiveCatalogTest.java b/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergHiveCatalogTest.java index e6352f9f89040..926afa473f9e8 100644 --- a/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergHiveCatalogTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergHiveCatalogTest.java @@ -17,22 +17,70 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Lists; +import com.starrocks.analysis.TableName; +import com.starrocks.catalog.Column; +import com.starrocks.catalog.IcebergView; +import com.starrocks.catalog.Table; +import com.starrocks.connector.HdfsEnvironment; import com.starrocks.connector.iceberg.hive.IcebergHiveCatalog; +import com.starrocks.sql.analyzer.AnalyzeTestUtil; +import com.starrocks.sql.ast.ColWithComment; +import com.starrocks.sql.ast.CreateViewStmt; +import com.starrocks.sql.parser.NodePosition; +import com.starrocks.utframe.UtFrameUtils; import mockit.Expectations; import mockit.Mocked; import org.apache.hadoop.conf.Configuration; +import org.apache.iceberg.Schema; import org.apache.iceberg.catalog.Namespace; import org.apache.iceberg.catalog.TableIdentifier; import org.apache.iceberg.hive.HiveCatalog; +import org.apache.iceberg.types.Types; +import org.apache.iceberg.view.BaseView; +import org.apache.iceberg.view.ImmutableSQLViewRepresentation; import org.junit.Assert; +import org.junit.BeforeClass; import org.junit.Test; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.Executors; + +import static com.starrocks.catalog.Table.TableType.ICEBERG_VIEW; +import static com.starrocks.catalog.Type.INT; +import static com.starrocks.connector.iceberg.IcebergCatalogProperties.HIVE_METASTORE_URIS; +import static com.starrocks.connector.iceberg.IcebergCatalogProperties.ICEBERG_CATALOG_TYPE; public class IcebergHiveCatalogTest { + private static final String CATALOG_NAME = "iceberg_hive_catalog"; + public static final Map DEFAULT_CONFIG = new HashMap<>(); + public static final IcebergCatalogProperties DEFAULT_CATALOG_PROPERTIES; + + public static final HdfsEnvironment HDFS_ENVIRONMENT = new HdfsEnvironment(); + static { + DEFAULT_CONFIG.put(HIVE_METASTORE_URIS, "thrift://188.122.12.1:8732"); // non-exist ip, prevent to connect local service + DEFAULT_CONFIG.put(ICEBERG_CATALOG_TYPE, "hive"); + DEFAULT_CATALOG_PROPERTIES = new IcebergCatalogProperties(DEFAULT_CONFIG); + } + + @BeforeClass + public static void beforeClass() throws Exception { + UtFrameUtils.createMinStarRocksCluster(); + AnalyzeTestUtil.init(); + } + + public IcebergMetadata buildIcebergMetadata(HiveCatalog hiveCatalog) { + IcebergHiveCatalog icebergHiveCatalog = new IcebergHiveCatalog(hiveCatalog, new Configuration()); + CachingIcebergCatalog cachingIcebergCatalog = new CachingIcebergCatalog( + CATALOG_NAME, icebergHiveCatalog, DEFAULT_CATALOG_PROPERTIES, Executors.newSingleThreadExecutor()); + + return new IcebergMetadata(CATALOG_NAME, HDFS_ENVIRONMENT, cachingIcebergCatalog, + Executors.newSingleThreadExecutor(), Executors.newSingleThreadExecutor(), + new IcebergCatalogProperties(DEFAULT_CONFIG)); + } @Test public void testListAllDatabases(@Mocked HiveCatalog hiveCatalog) { @@ -66,4 +114,63 @@ public void testRenameTable(@Mocked HiveCatalog hiveCatalog) { boolean exists = icebergHiveCatalog.tableExists("db", "tbl2"); Assert.assertTrue(exists); } + + @Test + public void testCreateView(@Mocked HiveCatalog hiveCatalog, @Mocked BaseView baseView, + @Mocked ImmutableSQLViewRepresentation representation) throws Exception { + IcebergMetadata metadata = buildIcebergMetadata(hiveCatalog); + + new Expectations() { + { + hiveCatalog.loadNamespaceMetadata(Namespace.of("db")); + result = ImmutableMap.of("location", "xxxxx"); + minTimes = 1; + } + }; + + CreateViewStmt stmt = new CreateViewStmt(false, false, new TableName("catalog", "db", "table"), + Lists.newArrayList(new ColWithComment("k1", "", NodePosition.ZERO)), "", false, null, NodePosition.ZERO); + stmt.setColumns(Lists.newArrayList(new Column("k1", INT))); + metadata.createView(stmt); + + new Expectations() { + { + representation.sql(); + result = "select * from table"; + minTimes = 1; + + baseView.sqlFor("starrocks"); + result = representation; + minTimes = 1; + + baseView.properties(); + result = ImmutableMap.of("comment", "mocked"); + minTimes = 1; + + baseView.schema(); + result = new Schema(Types.NestedField.optional(1, "k1", Types.IntegerType.get())); + minTimes = 1; + + baseView.name(); + result = "view"; + minTimes = 1; + + baseView.location(); + result = "xxx"; + minTimes = 1; + + hiveCatalog.loadView(TableIdentifier.of("db", "view")); + result = baseView; + minTimes = 1; + } + }; + + Table table = metadata.getView("db", "view"); + Assert.assertEquals(ICEBERG_VIEW, table.getType()); + Assert.assertEquals("xxx", table.getTableLocation()); + Assert.assertEquals("view", table.getName()); + IcebergView icebergView = (IcebergView) table; + Assert.assertEquals("select * from table", icebergView.getInlineViewDef()); + Assert.assertEquals("mocked", icebergView.getComment()); + } } diff --git a/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergRESTCatalogTest.java b/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergRESTCatalogTest.java index f98f1bf6eaaed..6662c1184625c 100644 --- a/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergRESTCatalogTest.java +++ b/fe/fe-core/src/test/java/com/starrocks/connector/iceberg/IcebergRESTCatalogTest.java @@ -54,18 +54,17 @@ import static com.starrocks.catalog.Table.TableType.ICEBERG_VIEW; import static com.starrocks.catalog.Type.INT; -import static com.starrocks.connector.iceberg.IcebergCatalogProperties.HIVE_METASTORE_URIS; import static com.starrocks.connector.iceberg.IcebergCatalogProperties.ICEBERG_CATALOG_TYPE; public class IcebergRESTCatalogTest { private static final String CATALOG_NAME = "iceberg_rest_catalog"; - public static final IcebergCatalogProperties DEFAULT_CATALOG_PROPERTIES; public static final Map DEFAULT_CONFIG = new HashMap<>(); + public static final IcebergCatalogProperties DEFAULT_CATALOG_PROPERTIES; + public static final HdfsEnvironment HDFS_ENVIRONMENT = new HdfsEnvironment(); static { - DEFAULT_CONFIG.put(HIVE_METASTORE_URIS, "thrift://188.122.12.1:8732"); // non-exist ip, prevent to connect local service - DEFAULT_CONFIG.put(ICEBERG_CATALOG_TYPE, "hive"); + DEFAULT_CONFIG.put(ICEBERG_CATALOG_TYPE, "rest"); DEFAULT_CATALOG_PROPERTIES = new IcebergCatalogProperties(DEFAULT_CONFIG); } @@ -185,10 +184,6 @@ public void testCreateView(@Mocked RESTCatalog restCatalog, @Mocked BaseView bas restCatalog.loadNamespaceMetadata(Namespace.of("db")); result = ImmutableMap.of("location", "xxxxx"); minTimes = 1; - - restCatalog.name(); - result = "rest_catalog"; - minTimes = 1; } }; diff --git a/test/sql/test_iceberg/R/test_iceberg_view b/test/sql/test_iceberg/R/test_iceberg_view new file mode 100644 index 0000000000000..df8b962f89527 --- /dev/null +++ b/test/sql/test_iceberg/R/test_iceberg_view @@ -0,0 +1,17 @@ +-- name: test_iceberg_view +create external catalog iceberg_sql_test_${uuid0} PROPERTIES ("type"="iceberg", "iceberg.catalog.type"="hive", "iceberg.catalog.hive.metastore.uris"="${iceberg_catalog_hive_metastore_uris}","enable_iceberg_metadata_cache"="true","aws.s3.access_key" = "${oss_ak}","aws.s3.secret_key" = "${oss_sk}","aws.s3.endpoint" = "${oss_endpoint}"); +-- result: +-- !result +create view iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view as select * from iceberg_sql_test_${uuid0}.iceberg_ci_db.day_partition; +-- result: +-- !result +select * from iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view; +-- result: +1 2024-08-08 15:32:51.751000 +-- !result +drop view iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view; +-- result: +-- !result +drop catalog iceberg_sql_test_${uuid0}; +-- result: +-- !result \ No newline at end of file diff --git a/test/sql/test_iceberg/T/test_iceberg_view b/test/sql/test_iceberg/T/test_iceberg_view new file mode 100644 index 0000000000000..0b81a9a2b7f22 --- /dev/null +++ b/test/sql/test_iceberg/T/test_iceberg_view @@ -0,0 +1,11 @@ +-- name: test_iceberg_view + +create external catalog iceberg_sql_test_${uuid0} PROPERTIES ("type"="iceberg", "iceberg.catalog.type"="hive", "iceberg.catalog.hive.metastore.uris"="${iceberg_catalog_hive_metastore_uris}","enable_iceberg_metadata_cache"="true","aws.s3.access_key" = "${oss_ak}","aws.s3.secret_key" = "${oss_sk}","aws.s3.endpoint" = "${oss_endpoint}"); + +create view iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view as select * from iceberg_sql_test_${uuid0}.iceberg_ci_db.day_partition; + +select * from iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view; + +drop view iceberg_sql_test_${uuid0}.iceberg_ci_db.test_iceberg_view; + +drop catalog iceberg_sql_test_${uuid0}; \ No newline at end of file