You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/07/16 20:51:07 UTC

[GitHub] [phoenix] swaroopak commented on a change in pull request #806: PHOENIX-5946: Implement SchemaExtractionTool utility to get effective…

swaroopak commented on a change in pull request #806:
URL: https://github.com/apache/phoenix/pull/806#discussion_r456070116



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/SchemaExtractionToolIT.java
##########
@@ -0,0 +1,164 @@
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
+import org.apache.phoenix.schema.SchemaExtractionTool;
+import org.apache.phoenix.util.PropertiesUtil;
+import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.util.Collections;
+
+import java.util.Map;
+import java.util.Properties;
+
+import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
+
+public class SchemaExtractionToolIT extends BaseTest {
+
+    @BeforeClass
+    public static void setup() throws Exception {
+        Map<String, String> props = Collections.emptyMap();
+        setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
+    }
+
+    @Test
+    public void testCreateTableStatement() throws Exception {
+        String tableName = generateUniqueName();
+        String schemaName = generateUniqueName();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        String properties = "TTL=2592000,IMMUTABLE_ROWS=true,DISABLE_MIGRATION=true,DISABLE_SOR=true,DISABLE_WAL=true";
+
+        try (Connection conn = DriverManager.getConnection(getUrl(), props)) {
+
+            String pTableFullName = SchemaUtil.getQualifiedTableName(schemaName, tableName);
+            conn.createStatement().execute("CREATE TABLE "+pTableFullName + "(k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)"
+                    + properties);
+            conn.commit();
+            String [] args = {"-tb", tableName, "-s", schemaName};
+
+            SchemaExtractionTool set = new SchemaExtractionTool();
+            set.setConf(conn.unwrap(PhoenixConnection.class).getQueryServices().getConfiguration());
+            set.run(args);
+            String actualProperties = set.output.substring(set.output.lastIndexOf(")")+1).replace(" ","");
+            Assert.assertEquals(5, actualProperties.split(",").length);

Review comment:
       I am going to heavily rely on Rachel's PR for test coverage if you don't mind. 




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org