This is an automated email from the ASF dual-hosted git repository.

peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git


The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
     new eeedd8eed add metadata unit test (#3559)
eeedd8eed is described below

commit eeedd8eed90cdfdbd9de79e4f5e8d7f52a1ee536
Author: ruY <[email protected]>
AuthorDate: Mon Oct 10 17:44:57 2022 +0800

    add metadata unit test (#3559)
    
    * feat: add metadata unit test
    
    * feat: Missing mode_info field addition
---
 linkis-dist/package/db/linkis_ddl.sql              |   1 +
 .../test/java/org/apache/linkis/metadata/Scan.java |  27 +++
 .../linkis/metadata/WebApplicationServer.java      |  34 +++
 .../condition/DataSourceConditionTest.java         |  33 +++
 .../apache/linkis/metadata/dao/BaseDaoTest.java    |  31 +++
 .../org/apache/linkis/metadata/dao/MdqDaoTest.java | 157 ++++++++++++++
 .../LinkisMetadataErrorCodeSummaryTest.java        |  45 ++++
 .../linkis/metadata/hive/dao/HiveMetaDaoTest.java  | 161 ++++++++++++++
 .../apache/linkis/metadata/type/LifecycleTest.java |  42 ++++
 .../linkis/metadata/type/ModelLevelTest.java       |  40 ++++
 .../linkis/metadata/type/UseWayTypeTest.java       |  40 ++++
 .../apache/linkis/metadata/util/ConstantsTest.java |  48 +++++
 .../apache/linkis/metadata/util/DWSConfigTest.java |  54 +++++
 .../apache/linkis/metadata/util/HiveUtilsTest.java |  43 ++++
 .../src/test/resources/application.properties      |  59 ++++++
 .../linkis-metadata/src/test/resources/create.sql  | 235 +++++++++++++++++++++
 .../src/test/resources/linkis.properties           |  21 ++
 17 files changed, 1071 insertions(+)

diff --git a/linkis-dist/package/db/linkis_ddl.sql 
b/linkis-dist/package/db/linkis_ddl.sql
index 36c7759c1..e87a84645 100644
--- a/linkis-dist/package/db/linkis_ddl.sql
+++ b/linkis-dist/package/db/linkis_ddl.sql
@@ -290,6 +290,7 @@ CREATE TABLE `linkis_ps_datasource_field` (
   `is_partition_field` tinyint(1) NOT NULL,
   `is_primary` tinyint(1) NOT NULL,
   `length` int(11) DEFAULT NULL,
+  `mode_info` varchar(128) COLLATE utf8_bin DEFAULT NULL,
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
 
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/Scan.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/Scan.java
new file mode 100644
index 000000000..485e1b6f9
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/Scan.java
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+
+import org.mybatis.spring.annotation.MapperScan;
+
+@EnableAutoConfiguration
+@MapperScan(
+    basePackages = {"org.apache.linkis.metadata.dao", 
"org.apache.linkis.metadata.hive.dao"})
+public class Scan {}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/WebApplicationServer.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/WebApplicationServer.java
new file mode 100644
index 000000000..2f84ec2c3
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/WebApplicationServer.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata;
+
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
+import org.springframework.boot.builder.SpringApplicationBuilder;
+import org.springframework.boot.web.servlet.ServletComponentScan;
+import 
org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
+import org.springframework.context.annotation.ComponentScan;
+
+@EnableAutoConfiguration
+@ServletComponentScan
+@ComponentScan
+public class WebApplicationServer extends SpringBootServletInitializer {
+
+  public static void main(String[] args) {
+    new SpringApplicationBuilder(WebApplicationServer.class).run(args);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/condition/DataSourceConditionTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/condition/DataSourceConditionTest.java
new file mode 100644
index 000000000..fcc432c94
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/condition/DataSourceConditionTest.java
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.condition;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class DataSourceConditionTest {
+
+  @Test
+  @DisplayName("matchesTest")
+  public void matchesTest() {
+
+    boolean matches = new DataSourceCondition().matches(null, null);
+    Assertions.assertTrue(matches);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/BaseDaoTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/BaseDaoTest.java
new file mode 100644
index 000000000..d1e08215c
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/BaseDaoTest.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.dao;
+
+import org.apache.linkis.metadata.Scan;
+
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.annotation.Rollback;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+import org.springframework.transaction.annotation.Transactional;
+
+@SpringBootTest(classes = Scan.class)
+@Transactional
+@Rollback(true)
+@EnableTransactionManagement
+public abstract class BaseDaoTest {}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/MdqDaoTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/MdqDaoTest.java
new file mode 100644
index 000000000..56da4160a
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/dao/MdqDaoTest.java
@@ -0,0 +1,157 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.dao;
+
+import org.apache.linkis.metadata.domain.mdq.po.MdqField;
+import org.apache.linkis.metadata.domain.mdq.po.MdqImport;
+import org.apache.linkis.metadata.domain.mdq.po.MdqLineage;
+import org.apache.linkis.metadata.domain.mdq.po.MdqTable;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class MdqDaoTest extends BaseDaoTest {
+
+  @Autowired private MdqDao mdqDao;
+
+  private MdqTable createMdpTable() {
+    MdqTable table = new MdqTable();
+    table.setDatabase("hadoop_ind");
+    table.setName("t_user");
+    table.setAlias("t_user");
+    table.setCreator("hadoop");
+    table.setComment("test create");
+    table.setCreateTime(new Date());
+    table.setUsage("test");
+    table.setLifecycle(0);
+    table.setUseWay(0);
+    table.setImport(false);
+    table.setModelLevel(0);
+    table.setPartitionTable(false);
+    table.setModelLevel(0);
+    table.setAvailable(true);
+    return table;
+  }
+
+  private MdqField createMdpField() {
+    MdqField mdqField = new MdqField();
+    mdqField.setTableId(1L);
+    mdqField.setName("name");
+    mdqField.setType("string");
+    mdqField.setComment("姓名字段");
+    mdqField.setPartitionField(false);
+    mdqField.setPrimary(false);
+    mdqField.setLength(255);
+    return mdqField;
+  }
+
+  @Test
+  @DisplayName("activateTableTest")
+  public void activateTableTest() {
+
+    mdqDao.activateTable(1L);
+    MdqTable mdqTable = mdqDao.selectTableForUpdate("ods_user_md_ind", 
"t_student_temp");
+    Assertions.assertTrue(mdqTable.getAvailable().booleanValue());
+  }
+
+  @Test
+  @DisplayName("selectTableByNameTest")
+  public void selectTableByNameTest() {
+    MdqTable mdqTable = mdqDao.selectTableByName("ods_user_md_ind", 
"t_student_temp", "hadoop");
+    Assertions.assertNotNull(mdqTable);
+  }
+
+  @Test
+  @DisplayName("listMdqFieldByTableIdTest")
+  public void listMdqFieldByTableIdTest() {
+
+    List<MdqField> mdqFields = mdqDao.listMdqFieldByTableId(1L);
+    Assertions.assertTrue(mdqFields.size() > 0);
+  }
+
+  @Test
+  @DisplayName("insertTableTest")
+  public void insertTableTest() {
+    MdqTable mdpTable = createMdpTable();
+    mdqDao.insertTable(mdpTable);
+    MdqTable mdqTableDao =
+        mdqDao.selectTableByName(mdpTable.getDatabase(), mdpTable.getName(), 
mdpTable.getCreator());
+    Assertions.assertNotNull(mdqTableDao);
+  }
+
+  @Test
+  @DisplayName("insertImportTest")
+  public void insertImportTest() {
+
+    Assertions.assertAll(
+        () -> {
+          MdqImport mdqImport = new MdqImport();
+          mdqImport.setTableId(1L);
+          mdqImport.setArgs("name");
+          mdqImport.setImportType(0);
+          mdqDao.insertImport(mdqImport);
+        });
+  }
+
+  @Test
+  @DisplayName("insertLineageTest")
+  public void insertLineageTest() {
+
+    Assertions.assertAll(
+        () -> {
+          MdqLineage mdqLineage = new MdqLineage();
+          mdqLineage.setTableId(1L);
+          mdqLineage.setSourceTable("hadoop_ind");
+          mdqLineage.setUpdateTime(new Date());
+          mdqDao.insertLineage(mdqLineage);
+        });
+  }
+
+  @Test
+  @DisplayName("selectTableForUpdateTest")
+  public void selectTableForUpdateTest() {
+    MdqTable mdqTable = mdqDao.selectTableForUpdate("ods_user_md_ind", 
"t_student_temp");
+    Assertions.assertNotNull(mdqTable);
+  }
+
+  @Test
+  @DisplayName("deleteTableBaseInfoTest")
+  public void deleteTableBaseInfoTest() {
+
+    mdqDao.deleteTableBaseInfo(1L);
+    MdqTable mdqTable = mdqDao.selectTableForUpdate("ods_user_md_ind", 
"t_student_temp");
+    Assertions.assertNull(mdqTable);
+  }
+
+  @Test
+  @DisplayName("insertFieldsTest")
+  public void insertFieldsTest() {
+    List<MdqField> list = new ArrayList<>(Arrays.asList(createMdpField()));
+    mdqDao.insertFields(list);
+    List<MdqField> mdqFields = mdqDao.listMdqFieldByTableId(1L);
+    Assertions.assertTrue(mdqFields.size() > 0);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/errorcode/LinkisMetadataErrorCodeSummaryTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/errorcode/LinkisMetadataErrorCodeSummaryTest.java
new file mode 100644
index 000000000..77a98c063
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/errorcode/LinkisMetadataErrorCodeSummaryTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.errorcode;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class LinkisMetadataErrorCodeSummaryTest {
+
+  @Test
+  @DisplayName("enumTest")
+  public void enumTest() {
+
+    int unrecognizedCode = 
LinkisMetadataErrorCodeSummary.UNRECOGNIZED_IMPORT_TYPE.getErrorCode();
+    int importHiveCode = 
LinkisMetadataErrorCodeSummary.IMPORT_HIVE_SOURCE_IS_NULL.getErrorCode();
+    int hiveCreateNullCode = 
LinkisMetadataErrorCodeSummary.HIVE_CREATE_IS_NULL.getErrorCode();
+    int hiveCreateTableNullCode =
+        
LinkisMetadataErrorCodeSummary.HIVE_CREATE__TABLE_IS_NULL.getErrorCode();
+    int partitionCode = 
LinkisMetadataErrorCodeSummary.PARTITION_IS_NULL.getErrorCode();
+    int expressCode = 
LinkisMetadataErrorCodeSummary.EXPRESS_CODE.getErrorCode();
+
+    Assertions.assertTrue(57895 == unrecognizedCode);
+    Assertions.assertTrue(57895 == importHiveCode);
+    Assertions.assertTrue(57895 == hiveCreateNullCode);
+    Assertions.assertTrue(57895 == hiveCreateTableNullCode);
+    Assertions.assertTrue(57895 == partitionCode);
+    Assertions.assertTrue(57895 == expressCode);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/hive/dao/HiveMetaDaoTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/hive/dao/HiveMetaDaoTest.java
new file mode 100644
index 000000000..87e072d35
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/hive/dao/HiveMetaDaoTest.java
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.hive.dao;
+
+import org.apache.linkis.metadata.dao.BaseDaoTest;
+import org.apache.linkis.metadata.hive.dto.MetadataQueryParam;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class HiveMetaDaoTest extends BaseDaoTest {
+
+  @Autowired private HiveMetaDao hiveMetaDao;
+
+  @Test
+  @DisplayName("getLocationByDbAndTableTest")
+  public void getLocationByDbAndTableTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+    String location = hiveMetaDao.getLocationByDbAndTable(queryParam);
+    Assertions.assertNotNull(location);
+  }
+
+  @Test
+  @DisplayName("getAllDbsTest")
+  public void getAllDbsTest() {
+
+    List<String> dbs = hiveMetaDao.getAllDbs();
+
+    Assertions.assertTrue(dbs.size() > 0);
+  }
+
+  @Test
+  @DisplayName("getRolesByUserTest")
+  public void getRolesByUserTest() {
+
+    List<String> roles = hiveMetaDao.getRolesByUser("admin");
+    Assertions.assertTrue(roles.size() == 0);
+  }
+
+  @Test
+  @DisplayName("getDbsByUserAndRolesTest")
+  public void getDbsByUserAndRolesTest() {
+
+    List<String> dbs = hiveMetaDao.getDbsByUserAndRoles("admin", new 
ArrayList<>());
+    Assertions.assertTrue(dbs.size() == 0);
+  }
+
+  @Test
+  @DisplayName("getTablesByDbNameAndUserAndRolesTest")
+  public void getTablesByDbNameAndUserAndRolesTest() {
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+    queryParam.setUserName("admin");
+    List<Map<String, Object>> tables = 
hiveMetaDao.getTablesByDbNameAndUserAndRoles(queryParam);
+    Assertions.assertTrue(tables.size() == 0);
+  }
+
+  @Test
+  @DisplayName("getTablesByDbNameTest")
+  public void getTablesByDbNameTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    List<Map<String, Object>> tables = 
hiveMetaDao.getTablesByDbName(queryParam);
+    Assertions.assertTrue(tables.size() == 1);
+  }
+
+  @Test
+  @DisplayName("getPartitionSizeTest")
+  public void getPartitionSizeTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+    queryParam.setPartitionName("ds=202202");
+
+    Long size = hiveMetaDao.getPartitionSize(queryParam);
+    Assertions.assertTrue(size.longValue() >= 0);
+  }
+
+  @Test
+  @DisplayName("getPartitionsTest")
+  public void getPartitionsTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+
+    List<String> partitions = hiveMetaDao.getPartitions(queryParam);
+    Assertions.assertTrue(partitions.size() >= 0);
+  }
+
+  @Test
+  @DisplayName("getColumnsTest")
+  public void getColumnsTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+
+    List<Map<String, Object>> columns = hiveMetaDao.getColumns(queryParam);
+    Assertions.assertTrue(columns.size() >= 0);
+  }
+
+  @Test
+  @DisplayName("getStorageDescriptionIDByDbTableNameAndUserTest")
+  public void getStorageDescriptionIDByDbTableNameAndUserTest() {
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+    queryParam.setUserName("admin");
+    Map<String, Object> list = 
hiveMetaDao.getStorageDescriptionIDByDbTableNameAndUser(queryParam);
+    Assertions.assertNull(list);
+  }
+
+  @Test
+  @DisplayName("getColumnsByStorageDescriptionIDTest")
+  public void getColumnsByStorageDescriptionIDTest() {
+
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setSdId("1");
+    List<Map<String, Object>> columns = 
hiveMetaDao.getColumnsByStorageDescriptionID(queryParam);
+    Assertions.assertTrue(columns.size() >= 0);
+  }
+
+  @Test
+  @DisplayName("getPartitionKeysTest")
+  public void getPartitionKeysTest() {
+    MetadataQueryParam queryParam = new MetadataQueryParam();
+    queryParam.setDbName("default");
+    queryParam.setTableName("employee");
+    List<Map<String, Object>> partitionKeys = 
hiveMetaDao.getPartitionKeys(queryParam);
+    Assertions.assertTrue(partitionKeys.size() > 0);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/LifecycleTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/LifecycleTest.java
new file mode 100644
index 000000000..d734d2452
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/LifecycleTest.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.type;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class LifecycleTest {
+
+  @Test
+  @DisplayName("enumTest")
+  public void enumTest() {
+
+    String permanentName = Lifecycle.Permanent.getName();
+    String halfYearName = Lifecycle.HalfYear.getName();
+    String thisMonthName = Lifecycle.ThisMonth.getName();
+    String thisWeekName = Lifecycle.ThisWeek.getName();
+    String toddayName = Lifecycle.Todday.getName();
+
+    Assertions.assertNotNull(permanentName);
+    Assertions.assertNotNull(halfYearName);
+    Assertions.assertNotNull(thisMonthName);
+    Assertions.assertNotNull(thisWeekName);
+    Assertions.assertNotNull(toddayName);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/ModelLevelTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/ModelLevelTest.java
new file mode 100644
index 000000000..4d26d8949
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/ModelLevelTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.type;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ModelLevelTest {
+
+  @Test
+  @DisplayName("enumTest")
+  public void enumTest() {
+
+    String odsName = ModelLevel.ODS.getName();
+    String dwdName = ModelLevel.DWD.getName();
+    String dwsName = ModelLevel.DWS.getName();
+    String adsName = ModelLevel.ADS.getName();
+
+    Assertions.assertEquals("原始数据层", odsName);
+    Assertions.assertEquals("明细数据层", dwdName);
+    Assertions.assertEquals("汇总数据层", dwsName);
+    Assertions.assertEquals("应用数据层", adsName);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/UseWayTypeTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/UseWayTypeTest.java
new file mode 100644
index 000000000..1db6c97a7
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/type/UseWayTypeTest.java
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.type;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class UseWayTypeTest {
+
+  @Test
+  @DisplayName("enumTest")
+  public void enumTest() {
+
+    String onceWriteMultiReadName = UseWayType.OnceWriteMultiRead.getName();
+    String multiOverwriteName = UseWayType.MultiOverwrite.getName();
+    String crudName = UseWayType.CRUD.getName();
+    String occasionllyReadName = UseWayType.OnceWriteOccasionllyRead.getName();
+
+    Assertions.assertEquals("一次写入多次读", onceWriteMultiReadName);
+    Assertions.assertEquals("多次覆盖写", multiOverwriteName);
+    Assertions.assertEquals("增删改查", crudName);
+    Assertions.assertEquals("一次写偶尔读", occasionllyReadName);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/ConstantsTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/ConstantsTest.java
new file mode 100644
index 000000000..642f6bbd3
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/ConstantsTest.java
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ConstantsTest {
+
+  @Test
+  @DisplayName("constTest")
+  public void constTest() {
+
+    String applicationName = Constants.APPLICATION_NAME;
+    String submitted = Constants.SUBMITTED;
+    String approved = Constants.APPROVED;
+    String rejected = Constants.REJECTED;
+    String column = Constants.COLUMN;
+    String row = Constants.ROW;
+    String table = Constants.TABLE;
+    String script = Constants.SCRIPT;
+
+    Assertions.assertNotNull(applicationName);
+    Assertions.assertNotNull(submitted);
+    Assertions.assertNotNull(approved);
+    Assertions.assertNotNull(rejected);
+    Assertions.assertNotNull(column);
+    Assertions.assertNotNull(row);
+    Assertions.assertNotNull(table);
+    Assertions.assertNotNull(script);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/DWSConfigTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/DWSConfigTest.java
new file mode 100644
index 000000000..2d27d320f
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/DWSConfigTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class DWSConfigTest {
+
+  @Test
+  @DisplayName("constTest")
+  public void constTest() {
+
+    String hiveConfDir = DWSConfig.HIVE_CONF_DIR.getValue();
+    String metaUrl = DWSConfig.HIVE_META_URL.getValue();
+    String metaUser = DWSConfig.HIVE_META_USER.getValue();
+    String hiveMetaPassword = DWSConfig.HIVE_META_PASSWORD.getValue();
+
+    Boolean encodeEnabled = DWSConfig.HIVE_PASS_ENCODE_ENABLED.getValue();
+    Boolean hivePermissionWithLOGINUserEnabled =
+        DWSConfig.HIVE_PERMISSION_WITH_lOGIN_USER_ENABLED.getValue();
+    String dbFilterKeywords = DWSConfig.DB_FILTER_KEYWORDS.getValue();
+    String hiveDbAdminUser = DWSConfig.HIVE_DB_ADMIN_USER.getValue();
+    String hdfsFileSystemRestErrs = DWSConfig.HDFS_FILE_SYSTEM_REST_ERRS;
+
+    Assertions.assertNotNull(hiveConfDir);
+    Assertions.assertNotNull(metaUrl);
+    Assertions.assertNotNull(metaUser);
+    Assertions.assertNotNull(hiveMetaPassword);
+
+    Assertions.assertFalse(encodeEnabled.booleanValue());
+    Assertions.assertTrue(hivePermissionWithLOGINUserEnabled.booleanValue());
+
+    Assertions.assertNotNull(dbFilterKeywords);
+    Assertions.assertNotNull(hiveDbAdminUser);
+    Assertions.assertNotNull(hdfsFileSystemRestErrs);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/HiveUtilsTest.java
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/HiveUtilsTest.java
new file mode 100644
index 000000000..5d61b9346
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/java/org/apache/linkis/metadata/util/HiveUtilsTest.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.linkis.metadata.util;
+
+import org.apache.hadoop.conf.Configuration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class HiveUtilsTest {
+
+  @Test
+  @DisplayName("getDefaultConfTest")
+  public void getDefaultConfTest() {
+
+    Configuration configuration = HiveUtils.getDefaultConf("hadoop");
+    Assertions.assertNotNull(configuration);
+  }
+
+  @Test
+  @DisplayName("decodeTest")
+  public void decodeTest() {
+
+    String hadoop = HiveUtils.decode("hadoop");
+    Assertions.assertNotNull(hadoop);
+  }
+}
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/application.properties
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/application.properties
new file mode 100644
index 000000000..5b519435c
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/application.properties
@@ -0,0 +1,59 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#wds.linkis.test.mode=true
+wds.linkis.server.version=v1
+
+#test
+wds.linkis.test.mode=true
+wds.linkis.test.user=hadoop
+
+
+##Linkis governance station administrators
+wds.linkis.governance.station.admin=hadoop
+wds.linkis.gateway.conf.publicservice.list=query,jobhistory,application,configuration,filesystem,udf,variable,microservice,errorcode,bml,datasource
+#
+
+#logging.level.root=debug
+#logging.file=./test.log
+#debug=true
+
+spring.datasource.driver-class-name=org.h2.Driver
+spring.datasource.url=jdbc:h2:mem:test;MODE=MySQL;DB_CLOSE_DELAY=-1;DATABASE_TO_LOWER=true;INIT=runscript
 from 'classpath:create.sql'
+spring.datasource.username=sa
+spring.datasource.password=
+spring.datasource.hikari.connection-test-query=select 1
+spring.datasource.hikari.minimum-idle=5
+spring.datasource.hikari.auto-commit=true
+spring.datasource.hikari.validation-timeout=3000
+spring.datasource.hikari.pool-name=linkis-test
+spring.datasource.hikari.maximum-pool-size=50
+spring.datasource.hikari.connection-timeout=30000
+spring.datasource.hikari.idle-timeout=600000
+spring.datasource.hikari.leak-detection-threshold=0
+spring.datasource.hikari.initialization-fail-timeout=1
+
+spring.main.web-application-type=servlet
+server.port=1234
+spring.h2.console.enabled=true
+
+#disable eureka discovery client
+spring.cloud.service-registry.auto-registration.enabled=false
+eureka.client.enabled=false
+eureka.client.serviceUrl.registerWithEureka=false
+
+mybatis-plus.mapper-locations=classpath:org/apache/linkis/metadata/dao/impl/MdqDao.xml,classpath:org/apache/linkis/metadata/hive/dao/impl/HiveMetaDao.xml
+mybatis-plus.type-aliases-package=org.apache.linkis.metadata.domain.mdq.po
+mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/create.sql
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/create.sql
new file mode 100644
index 000000000..b01112c8b
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/create.sql
@@ -0,0 +1,235 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+
+SET FOREIGN_KEY_CHECKS=0;
+SET REFERENTIAL_INTEGRITY FALSE;
+
+DROP TABLE IF EXISTS linkis_ps_datasource_table CASCADE;
+CREATE TABLE linkis_ps_datasource_table (
+  id bigint(255)  AUTO_INCREMENT,
+  database varchar(64)  ,
+  name varchar(64)  ,
+  alias varchar(64)  DEFAULT NULL,
+  creator varchar(16)  ,
+  comment varchar(255)  DEFAULT NULL,
+  create_time datetime ,
+  product_name varchar(64)  DEFAULT NULL,
+  project_name varchar(255)  DEFAULT NULL,
+  usage varchar(128)  DEFAULT NULL,
+  lifecycle int(4) ,
+  use_way int(4) ,
+  is_import tinyint(1) ,
+  model_level int(4) ,
+  is_external_use tinyint(1) ,
+  is_partition_table tinyint(1) ,
+  is_available tinyint(1) ,
+  PRIMARY KEY (id),
+  UNIQUE KEY database (database,name)
+) ;
+
+DROP TABLE IF EXISTS linkis_ps_datasource_field CASCADE;
+CREATE TABLE linkis_ps_datasource_field (
+  id bigint(20)  AUTO_INCREMENT,
+  table_id bigint(20) ,
+  name varchar(64)  ,
+  alias varchar(64)  DEFAULT NULL,
+  type varchar(64)  ,
+  comment varchar(255)  DEFAULT NULL,
+  express varchar(255)  DEFAULT NULL,
+  rule varchar(128)  DEFAULT NULL,
+  is_partition_field tinyint(1) ,
+  is_primary tinyint(1) ,
+  length int(11) DEFAULT NULL,
+  mode_info varchar(128)  DEFAULT NULL,
+  PRIMARY KEY (id)
+) ;
+
+DROP TABLE IF EXISTS linkis_ps_datasource_import CASCADE;
+CREATE TABLE linkis_ps_datasource_import (
+  id bigint(20)  AUTO_INCREMENT,
+  table_id bigint(20) ,
+  import_type int(4) ,
+  args varchar(255)  ,
+  PRIMARY KEY (id)
+) ;
+
+DROP TABLE IF EXISTS linkis_ps_datasource_lineage CASCADE;
+CREATE TABLE linkis_ps_datasource_lineage (
+  id bigint(20)  AUTO_INCREMENT,
+  table_id bigint(20) DEFAULT NULL,
+  source_table varchar(64)  DEFAULT NULL,
+  update_time datetime DEFAULT NULL,
+  PRIMARY KEY (id)
+) ;
+
+
+INSERT INTO linkis_ps_datasource_table 
(database,name,alias,creator,comment,create_time,product_name,project_name,usage,lifecycle,use_way,is_import,model_level,is_external_use,is_partition_table,is_available)
 VALUES
+        
('ods_user_md_ind','t_student_temp','t_student_temp','hadoop','','2022-04-14 
18:53:20','','','测试',0,2,0,0,0,1,1);
+INSERT INTO linkis_ps_datasource_field 
(table_id,name,alias,type,comment,express,rule,is_partition_field,is_primary,length)
 VALUES
+     (1,'name','','string','',null,null,0,0,255);
+INSERT INTO linkis_ps_datasource_import (table_id,import_type,args) VALUES 
(1,1,'where 1=1');
+INSERT INTO linkis_ps_datasource_lineage (table_id,source_table) VALUES 
(1,'db_test');
+
+DROP TABLE IF EXISTS DBS CASCADE;
+CREATE TABLE DBS (
+  DB_ID bigint(20) ,
+  DESC varchar(256)  DEFAULT NULL,
+  DB_LOCATION_URI varchar(4000) ,
+  NAME varchar(128)   DEFAULT NULL,
+  OWNER_NAME varchar(128)   DEFAULT NULL,
+  OWNER_TYPE varchar(10)   DEFAULT NULL,
+  CTLG_NAME varchar(256) DEFAULT 'hive',
+  PRIMARY KEY (DB_ID)
+) ;
+
+DROP TABLE IF EXISTS SDS CASCADE;
+CREATE TABLE SDS (
+  SD_ID bigint(20) ,
+  CD_ID bigint(20) DEFAULT NULL,
+  INPUT_FORMAT varchar(4000)  DEFAULT NULL,
+  IS_COMPRESSED bit(1) ,
+  IS_STOREDASSUBDIRECTORIES bit(1) ,
+  LOCATION varchar(4000)  DEFAULT NULL,
+  NUM_BUCKETS int(11) ,
+  OUTPUT_FORMAT varchar(4000)  DEFAULT NULL,
+  SERDE_ID bigint(20) DEFAULT NULL,
+  PRIMARY KEY (SD_ID)
+) ;
+
+DROP TABLE IF EXISTS TBLS CASCADE;
+CREATE TABLE TBLS (
+  TBL_ID bigint(20) ,
+  CREATE_TIME int(11) ,
+  DB_ID bigint(20) DEFAULT NULL,
+  LAST_ACCESS_TIME int(11) ,
+  OWNER varchar(767)  DEFAULT NULL,
+  OWNER_TYPE varchar(10)  DEFAULT NULL,
+  RETENTION int(11) ,
+  SD_ID bigint(20) DEFAULT NULL,
+  TBL_NAME varchar(256)  DEFAULT NULL,
+  TBL_TYPE varchar(128)  DEFAULT NULL,
+  VIEW_EXPANDED_TEXT mediumtext,
+  VIEW_ORIGINAL_TEXT mediumtext,
+  IS_REWRITE_ENABLED bit(1) ,
+  PRIMARY KEY (TBL_ID)
+) ;
+
+INSERT INTO DBS 
(DB_ID,DESC,DB_LOCATION_URI,NAME,OWNER_NAME,OWNER_TYPE,CTLG_NAME) VALUES
+        (1,'Default Hive 
database','hdfs://hadoops/user/hive/warehouse','default','public','ROLE','hive');
+INSERT INTO TBLS 
(TBL_ID,CREATE_TIME,DB_ID,LAST_ACCESS_TIME,OWNER,OWNER_TYPE,RETENTION,SD_ID,TBL_NAME,TBL_TYPE,VIEW_EXPANDED_TEXT,VIEW_ORIGINAL_TEXT,IS_REWRITE_ENABLED)
 VALUES
+        
(1,1648518600,1,0,'hadoop','USER',0,1,'employee','MANAGED_TABLE',NULL,NULL,0);
+INSERT INTO SDS 
(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID)
 VALUES
+        
(1,1,'org.apache.hadoop.mapred.TextInputFormat',0,0,'hdfs://hadoops/user/hive/warehouse/hivedemo.db/employee',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',1);
+
+DROP TABLE IF EXISTS ROLES CASCADE;
+CREATE TABLE ROLES (
+  ROLE_ID bigint(20) ,
+  CREATE_TIME int(11) ,
+  OWNER_NAME varchar(128)  DEFAULT NULL,
+  ROLE_NAME varchar(128)  DEFAULT NULL,
+  PRIMARY KEY (ROLE_ID)
+) ;
+
+DROP TABLE IF EXISTS ROLE_MAP CASCADE;
+CREATE TABLE ROLE_MAP (
+  ROLE_GRANT_ID bigint(20) ,
+  ADD_TIME int(11) ,
+  GRANT_OPTION smallint(6) ,
+  GRANTOR varchar(128)  DEFAULT NULL,
+  GRANTOR_TYPE varchar(128)  DEFAULT NULL,
+  PRINCIPAL_NAME varchar(128)  DEFAULT NULL,
+  PRINCIPAL_TYPE varchar(128)  DEFAULT NULL,
+  ROLE_ID bigint(20) DEFAULT NULL,
+  PRIMARY KEY (ROLE_GRANT_ID)
+) ;
+
+DROP TABLE IF EXISTS DB_PRIVS CASCADE;
+CREATE TABLE DB_PRIVS (
+  DB_GRANT_ID bigint(20) ,
+  CREATE_TIME int(11) ,
+  DB_ID bigint(20) DEFAULT NULL,
+  GRANT_OPTION smallint(6) ,
+  GRANTOR varchar(128)  DEFAULT NULL,
+  GRANTOR_TYPE varchar(128)  DEFAULT NULL,
+  PRINCIPAL_NAME varchar(128)  DEFAULT NULL,
+  PRINCIPAL_TYPE varchar(128)  DEFAULT NULL,
+  DB_PRIV varchar(128)  DEFAULT NULL,
+  AUTHORIZER varchar(128)  DEFAULT NULL,
+  PRIMARY KEY (DB_GRANT_ID)
+) ;
+
+DROP TABLE IF EXISTS TBL_PRIVS CASCADE;
+CREATE TABLE TBL_PRIVS (
+  TBL_GRANT_ID bigint(20) ,
+  CREATE_TIME int(11) ,
+  GRANT_OPTION smallint(6) ,
+  GRANTOR varchar(128)  DEFAULT NULL,
+  GRANTOR_TYPE varchar(128)  DEFAULT NULL,
+  PRINCIPAL_NAME varchar(128)  DEFAULT NULL,
+  PRINCIPAL_TYPE varchar(128)  DEFAULT NULL,
+  TBL_PRIV varchar(128)  DEFAULT NULL,
+  TBL_ID bigint(20) DEFAULT NULL,
+  AUTHORIZER varchar(128)  DEFAULT NULL,
+  PRIMARY KEY (TBL_GRANT_ID)
+) ;
+
+DROP TABLE IF EXISTS PARTITION_PARAMS CASCADE;
+CREATE TABLE PARTITION_PARAMS (
+  PART_ID bigint(20) ,
+  PARAM_KEY varchar(256) ,
+  PARAM_VALUE varchar(4000)  DEFAULT NULL,
+  PRIMARY KEY (PART_ID,PARAM_KEY)
+) ;
+
+DROP TABLE IF EXISTS PARTITIONS CASCADE;
+CREATE TABLE PARTITIONS (
+  PART_ID bigint(20) ,
+  CREATE_TIME int(11) ,
+  LAST_ACCESS_TIME int(11) ,
+  PART_NAME varchar(767)  DEFAULT NULL,
+  SD_ID bigint(20) DEFAULT NULL,
+  TBL_ID bigint(20) DEFAULT NULL,
+  PRIMARY KEY (PART_ID)
+) ;
+
+DROP TABLE IF EXISTS COLUMNS_V2 CASCADE;
+CREATE TABLE COLUMNS_V2 (
+  CD_ID bigint(20) ,
+  COMMENT varchar(256) DEFAULT NULL,
+  COLUMN_NAME varchar(767) ,
+  TYPE_NAME mediumtext ,
+  INTEGER_IDX int(11) ,
+  PRIMARY KEY (CD_ID,COLUMN_NAME)
+) ;
+
+DROP TABLE IF EXISTS PARTITION_KEYS CASCADE;
+CREATE TABLE PARTITION_KEYS (
+  TBL_ID bigint(20) ,
+  PKEY_COMMENT varchar(4000)  DEFAULT NULL,
+  PKEY_NAME varchar(128),
+  PKEY_TYPE varchar(767) ,
+  INTEGER_IDX int(11) ,
+  PRIMARY KEY (TBL_ID,PKEY_NAME)
+) ;
+
+INSERT INTO ROLES (ROLE_ID,CREATE_TIME,OWNER_NAME,ROLE_NAME) VALUES 
(2,1647872356,'public','public');
+INSERT INTO PARTITION_PARAMS (PART_ID,PARAM_KEY,PARAM_VALUE) VALUES 
(3,'totalSize',3);
+INSERT INTO PARTITIONS 
(PART_ID,CREATE_TIME,LAST_ACCESS_TIME,PART_NAME,SD_ID,TBL_ID) VALUES
+ (3,1650266917,0,'ds=202202',1,1);
+INSERT INTO COLUMNS_V2 (CD_ID,COMMENT,COLUMN_NAME,TYPE_NAME,INTEGER_IDX) 
VALUES (1,'','destination','string',0);
+INSERT INTO PARTITION_KEYS 
(TBL_ID,PKEY_COMMENT,PKEY_NAME,PKEY_TYPE,INTEGER_IDX) VALUES
+ (1,'','ds','string',0);
\ No newline at end of file
diff --git 
a/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/linkis.properties
 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/linkis.properties
new file mode 100644
index 000000000..1c575edc5
--- /dev/null
+++ 
b/linkis-public-enhancements/linkis-datasource/linkis-metadata/src/test/resources/linkis.properties
@@ -0,0 +1,21 @@
+# 
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+# http://www.apache.org/licenses/LICENSE-2.0
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#wds.linkis.test.mode=true
+wds.linkis.server.version=v1
+
+#test
+wds.linkis.test.mode=true
+wds.linkis.test.user=hadoop
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to