[ https://issues.apache.org/jira/browse/HIVE-25630?focusedWorklogId=669454&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-669454 ]
ASF GitHub Bot logged work on HIVE-25630: ----------------------------------------- Author: ASF GitHub Bot Created on: 25/Oct/21 10:41 Start Date: 25/Oct/21 10:41 Worklog Time Spent: 10m Work Description: kasakrisz commented on a change in pull request #2738: URL: https://github.com/apache/hive/pull/2738#discussion_r735474163 ########## File path: standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreTransformer.java ########## @@ -0,0 +1,130 @@ +/* + * 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.hadoop.hive.metastore; + +import java.util.ArrayList; +import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; +import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; +import org.junit.After; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.api.FieldSchema; +import org.apache.hadoop.hive.metastore.api.InvalidOperationException; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.util.StringUtils; +import org.apache.thrift.TException; +import org.junit.Test; + +public class TestMetastoreTransformer { + private static final Logger LOG = LoggerFactory.getLogger(TestMetastoreTransformer.class); + protected static HiveMetaStoreClient client; + protected static Configuration conf = null; + protected static Warehouse warehouse; + protected static boolean isThriftClient = false; + + @Before + public void setUp() throws Exception { + initConf(); + warehouse = new Warehouse(conf); + + // set some values to use for getting conf. vars + MetastoreConf.setBoolVar(conf, ConfVars.METRICS_ENABLED, true); + conf.set("datanucleus.autoCreateTables", "false"); + conf.set("hive.in.test", "true"); + + MetaStoreTestUtils.setConfForStandloneMode(conf); + + warehouse = new Warehouse(conf); + client = createClient(); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + protected HiveMetaStoreClient createClient() throws Exception { + try { + return new HiveMetaStoreClient(conf); + } catch (Throwable e) { + System.err.println("Unable to open the metastore"); + System.err.println(StringUtils.stringifyException(e)); + throw new Exception(e); + } + } + + protected void initConf() { + if (null == conf) { + conf = MetastoreConf.newMetastoreConf(); + } + } + + private static void silentDropDatabase(String dbName) throws TException { + try { + for (String tableName : client.getTables(dbName, "*")) { + client.dropTable(dbName, tableName); + } + client.dropDatabase(dbName); + } catch (NoSuchObjectException | InvalidOperationException | MetaException e) { + // NOP + } + } + + @Test + public void testAlterTableIsCaseInSensitive() throws Exception { + String dbName = "alterdb"; + String tblName = "altertbl"; + + client.dropTable(dbName, tblName); + silentDropDatabase(dbName); + + String dbLocation = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL) + "/_testDB_table_create_"; + String mgdLocation = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) + "/_testDB_table_create_"; + new DatabaseBuilder().setName(dbName).setLocation(dbLocation).setManagedLocation(mgdLocation).create(client, conf); + + ArrayList<FieldSchema> invCols = new ArrayList<>(2); + invCols.add(new FieldSchema("n-ame", ColumnType.STRING_TYPE_NAME, "")); + invCols.add(new FieldSchema("in.come", ColumnType.INT_TYPE_NAME, "")); + + Table tbl = new TableBuilder().setDbName(dbName).setTableName(tblName).setCols(invCols).build(conf); + + client.createTable(tbl); + tbl = client.getTable(tbl.getDbName(), tbl.getTableName()); + tbl.setTableName(tblName.toUpperCase()); + client.alter_table(tbl.getDbName(), tbl.getTableName().toUpperCase(), tbl); + Review comment: Should the new table name be asserted? ########## File path: standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetastoreTransformer.java ########## @@ -0,0 +1,130 @@ +/* + * 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.hadoop.hive.metastore; + +import java.util.ArrayList; +import org.apache.hadoop.hive.metastore.client.builder.DatabaseBuilder; +import org.apache.hadoop.hive.metastore.client.builder.TableBuilder; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf; +import org.apache.hadoop.hive.metastore.conf.MetastoreConf.ConfVars; +import org.junit.After; +import org.junit.Before; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.hive.metastore.api.FieldSchema; +import org.apache.hadoop.hive.metastore.api.InvalidOperationException; +import org.apache.hadoop.hive.metastore.api.MetaException; +import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; +import org.apache.hadoop.hive.metastore.api.Table; +import org.apache.hadoop.util.StringUtils; +import org.apache.thrift.TException; +import org.junit.Test; + +public class TestMetastoreTransformer { + private static final Logger LOG = LoggerFactory.getLogger(TestMetastoreTransformer.class); + protected static HiveMetaStoreClient client; + protected static Configuration conf = null; + protected static Warehouse warehouse; + protected static boolean isThriftClient = false; + + @Before + public void setUp() throws Exception { + initConf(); + warehouse = new Warehouse(conf); + + // set some values to use for getting conf. vars + MetastoreConf.setBoolVar(conf, ConfVars.METRICS_ENABLED, true); + conf.set("datanucleus.autoCreateTables", "false"); + conf.set("hive.in.test", "true"); + + MetaStoreTestUtils.setConfForStandloneMode(conf); + + warehouse = new Warehouse(conf); + client = createClient(); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + protected HiveMetaStoreClient createClient() throws Exception { + try { + return new HiveMetaStoreClient(conf); + } catch (Throwable e) { + System.err.println("Unable to open the metastore"); + System.err.println(StringUtils.stringifyException(e)); + throw new Exception(e); + } + } + + protected void initConf() { + if (null == conf) { + conf = MetastoreConf.newMetastoreConf(); + } + } + + private static void silentDropDatabase(String dbName) throws TException { + try { + for (String tableName : client.getTables(dbName, "*")) { + client.dropTable(dbName, tableName); + } + client.dropDatabase(dbName); + } catch (NoSuchObjectException | InvalidOperationException | MetaException e) { + // NOP + } + } + + @Test + public void testAlterTableIsCaseInSensitive() throws Exception { + String dbName = "alterdb"; + String tblName = "altertbl"; + + client.dropTable(dbName, tblName); + silentDropDatabase(dbName); + + String dbLocation = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE_EXTERNAL) + "/_testDB_table_create_"; + String mgdLocation = MetastoreConf.getVar(conf, ConfVars.WAREHOUSE) + "/_testDB_table_create_"; + new DatabaseBuilder().setName(dbName).setLocation(dbLocation).setManagedLocation(mgdLocation).create(client, conf); + + ArrayList<FieldSchema> invCols = new ArrayList<>(2); + invCols.add(new FieldSchema("n-ame", ColumnType.STRING_TYPE_NAME, "")); + invCols.add(new FieldSchema("in.come", ColumnType.INT_TYPE_NAME, "")); + + Table tbl = new TableBuilder().setDbName(dbName).setTableName(tblName).setCols(invCols).build(conf); + + client.createTable(tbl); + tbl = client.getTable(tbl.getDbName(), tbl.getTableName()); + tbl.setTableName(tblName.toUpperCase()); + client.alter_table(tbl.getDbName(), tbl.getTableName().toUpperCase(), tbl); + + } + + @Test + public void testLocationBlank() throws Exception { + Table tbl = + new TableBuilder().setTableName("locationBlank").setCols(new ArrayList<FieldSchema>()).setLocation("") + .build(conf); + + client.createTable(tbl); + Review comment: Should the newly created table exists be asserted? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org Issue Time Tracking ------------------- Worklog Id: (was: 669454) Time Spent: 0.5h (was: 20m) > Transformer fixes > ----------------- > > Key: HIVE-25630 > URL: https://issues.apache.org/jira/browse/HIVE-25630 > Project: Hive > Issue Type: Improvement > Reporter: Zoltan Haindrich > Assignee: Zoltan Haindrich > Priority: Major > Labels: pull-request-available > Time Spent: 0.5h > Remaining Estimate: 0h > > there are some issues: > * AlreadyExistsException might be suppressed by the translator > * uppercase letter usage may cause problems for some clients > * add a way to suppress location checks for legacy clients -- This message was sent by Atlassian Jira (v8.3.4#803005)