[
https://issues.apache.org/jira/browse/DRILL-5295?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15883406#comment-15883406
]
Akira Matsuo commented on DRILL-5295:
-------------------------------------
It seems like some of the code in InfoSchemaRecordGenerator regarding visiting
tables handles null table types and other parts don't. The configuration in
question where this error occurs is defined as a:
{
"type": "jdbc",
"driver": "com.mysql.jdbc.Driver",
... rest of config
}
Not sure if it's the correct way to solve this issue but as work around I've
patched our drill to ignore null table types. Not sure why I had to check for
nulls in both places as visitTableWithType is private and should only be called
if shouldVisitTable == true. As a reference I've included the patch in this
comment below:
<<< PATCH FOLLOWS >>
diff --git
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaRecordGenerator.java
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaRecordGenerator.java
index aee3dc1..a9404f5 100644
---
a/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaRecordGenerator.java
+++
b/exec/java-exec/src/main/java/org/apache/drill/exec/store/ischema/InfoSchemaRecordGenerator.java
@@ -156,6 +156,10 @@ public abstract class InfoSchemaRecordGenerator<S> {
if (filter == null) {
return true;
}
+ // Don't think we should be visiting tables with null tableType.
+ if (tableType == null) {
+ return false;
+ }
final Map<String, String> recordValues =
ImmutableMap.of(
@@ -311,9 +315,15 @@ public abstract class InfoSchemaRecordGenerator<S> {
}
private void visitTableWithType(String schemaName, String tableName,
TableType type) {
+ // fail gracefully instead of NPE on precondition, not sure why this is
necessary if
+ // shouldVisitTable() has already been modified to handle null tableTypes
+ if (type == null) {
+ return;
+ }
+ // don't think precondition is necessary anymore, will leave it in for
now
Preconditions
- .checkNotNull(type, "Error. Type information for table %s.%s
provided is null.", schemaName,
- tableName);
+ .checkNotNull(type, "Error. Type information for table %s.%s provided
is null.", schemaName,
+ tableName);
records.add(new Records.Table(IS_CATALOG_NAME, schemaName, tableName,
type.toString()));
return;
}
> Unable to query INFORMATION_SCHEMA.`TABLES` if MySql storage plugin enabled
> ---------------------------------------------------------------------------
>
> Key: DRILL-5295
> URL: https://issues.apache.org/jira/browse/DRILL-5295
> Project: Apache Drill
> Issue Type: Bug
> Affects Versions: 1.9.0
> Environment: Drill 1.9. Error can be reproduced running Drill locally
> on Windows and on Linux within zookeeper. I can reproduce it with 2 mysql
> servers.
> Reporter: Martina Ponca
>
> Impact: Unable to connect from Qlik Sense to Drill because of MySql Storage
> Plugin enabled.
> Steps to repro:
> 1. Create a new storage plugin to MySql Community Edition 5.5.43. Enable it.
> 2. Run query: "select * from INFORMATION_SCHEMA.`TABLES`"
> 3. Error:
> {code}
> Error: SYSTEM ERROR: NullPointerException: Error. Type information for table
> bistoremysql.information_schema.CHARACTER_SETS provided is null.
> Fragment 0:0
> [Error Id: 2717cfe1-413d-4330-ab3f-720ae92ebc50 on
> mycomputer.domain.lan:31010]
> (java.lang.NullPointerException) Error. Type information for table
> bistoremysql.information_schema.CHARACTER_SETS provided is null.
> com.google.common.base.Preconditions.checkNotNull():250
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator$Tables.visitTableWithType():314
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator$Tables.visitTables():308
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator.scanSchema():215
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator.scanSchema():208
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator.scanSchema():208
>
> org.apache.drill.exec.store.ischema.InfoSchemaRecordGenerator.scanSchema():195
>
> org.apache.drill.exec.store.ischema.InfoSchemaTableType.getRecordReader():58
> org.apache.drill.exec.store.ischema.InfoSchemaBatchCreator.getBatch():36
> org.apache.drill.exec.store.ischema.InfoSchemaBatchCreator.getBatch():30
> org.apache.drill.exec.physical.impl.ImplCreator.getRecordBatch():148
> org.apache.drill.exec.physical.impl.ImplCreator.getChildren():171
> org.apache.drill.exec.physical.impl.ImplCreator.getRecordBatch():128
> org.apache.drill.exec.physical.impl.ImplCreator.getChildren():171
> org.apache.drill.exec.physical.impl.ImplCreator.getRootExec():101
> org.apache.drill.exec.physical.impl.ImplCreator.getExec():79
> org.apache.drill.exec.work.fragment.FragmentExecutor.run():206
> org.apache.drill.common.SelfCleaningRunnable.run():38
> java.util.concurrent.ThreadPoolExecutor.runWorker():1145
> java.util.concurrent.ThreadPoolExecutor$Worker.run():615
> java.lang.Thread.run():745 (state=,code=0)
> {code}
> The full query Qlik Sense runs:
> {code:sql}
> select TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE from
> INFORMATION_SCHEMA.`TABLES` WHERE TABLE_CATALOG LIKE 'DRILL' ESCAPE '\' AND
> TABLE_SCHEMA <> 'sys' AND TABLE_SCHEMA <> 'INFORMATION_SCHEMA'ORDER BY
> TABLE_TYPE, TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME
> {code}
> If I disable the mysql storage plugin, I can run the query and connect from
> Qlik (not a workaround).
> This issue cannot be reproduced using Drill 1.5.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)