You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2021/10/08 14:35:21 UTC

[GitHub] [drill] vvysotskyi commented on a change in pull request #2327: DRILL-8005: Add Writer to JDBC Storage Plugin

vvysotskyi commented on a change in pull request #2327:
URL: https://github.com/apache/drill/pull/2327#discussion_r725064774



##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/JdbcStoragePlugin.java
##########
@@ -81,7 +80,12 @@ public boolean supportsRead() {
     return true;
   }
 
-  public DataSource getDataSource() {
+  @Override
+  public boolean supportsWrite() {
+    return config.isWritable();
+  }
+
+  public HikariDataSource getDataSource() {

Review comment:
       Is there any reason for returning `HikariDataSource` here instead of `DataSource`? We should not depend on the specific implementation.

##########
File path: docs/dev/CreatingAWriter.md
##########
@@ -0,0 +1,2 @@
+# Creating a Writer for a Storage Plugin
+This tutorial explains the mostly undocumented features of how to create a writer for a Drill storage plugin.  

Review comment:
       Looks like it should be added.

##########
File path: .gitignore
##########
@@ -27,3 +27,4 @@ exec/jdbc-all/dependency-reduced-pom.xml
 .*.html
 venv/
 tools/venv/
+contrib/storage-jdbc/src/test/resources/logback-test.xml

Review comment:
       Please remove this line, it is not needed.

##########
File path: contrib/storage-jdbc/pom.xml
##########
@@ -30,10 +30,18 @@
 
   <name>Drill : Contrib : Storage : JDBC</name>
 
+  <repositories>
+    <repository>
+      <id>jitpack.io</id>
+      <url>https://jitpack.io</url>
+    </repository>
+  </repositories>
+

Review comment:
       It is declared in root pom, so no need to declare it here too.

##########
File path: contrib/storage-jdbc/src/main/java/org/apache/drill/exec/store/jdbc/CapitalizingJdbcSchema.java
##########
@@ -93,6 +110,65 @@ void setHolder(SchemaPlus plusOfThis) {
     return inner.getTableNames();
   }
 
+
+  @Override
+  public CreateTableEntry createNewTable(String tableName, List<String> partitionColumns, StorageStrategy strategy) {
+    if (! plugin.getConfig().isWritable()) {
+      throw UserException
+        .dataWriteError()
+        .message(plugin.getName() + " is not writable.")
+        .build(logger);
+    }
+
+    return new CreateTableEntry() {
+
+      @Override
+      public Writer getWriter(PhysicalOperator child) throws IOException {
+        String tableWithSchema = JdbcQueryBuilder.buildCompleteTableName(tableName, catalog, schema);
+        return new JdbcWriter(child, tableWithSchema, inner, plugin);
+      }
+
+      @Override
+      public List<String> getPartitionColumns() {
+        return Collections.emptyList();
+      }
+    };
+  }
+
+  @Override
+  public void dropTable(String tableName) {
+    String tableWithSchema = JdbcQueryBuilder.buildCompleteTableName(tableName, catalog, schema);
+    String dropTableQuery = String.format("DROP TABLE %s", tableWithSchema);
+    dropTableQuery = JdbcDDLQueryUtils.cleanDDLQuery(dropTableQuery, plugin.getDialect());
+
+    try {
+      Connection conn = inner.getDataSource().getConnection();
+      Statement stmt = conn.createStatement();

Review comment:
       Please wrap it with a try-with-resources.




-- 
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: dev-unsubscribe@drill.apache.org

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