Github user qiuchenjian commented on a diff in the pull request: https://github.com/apache/carbondata/pull/2982#discussion_r240233846 --- Diff: integration/presto/src/main/java/org/apache/carbondata/presto/impl/CarbonTableReader.java --- @@ -364,23 +355,38 @@ private CarbonTable parseCarbonMetadata(SchemaTableName table) { String tablePath = storePath + "/" + carbonTableIdentifier.getDatabaseName() + "/" + carbonTableIdentifier.getTableName(); - //Step 2: read the metadata (tableInfo) of the table. - ThriftReader.TBaseCreator createTBase = new ThriftReader.TBaseCreator() { - // TBase is used to read and write thrift objects. - // TableInfo is a kind of TBase used to read and write table information. - // TableInfo is generated by thrift, - // see schema.thrift under format/src/main/thrift for details. - public TBase create() { - return new org.apache.carbondata.format.TableInfo(); + String metadataPath = CarbonTablePath.getSchemaFilePath(tablePath); + boolean isTransactionalTable = false; + try { + if (FileFactory.getCarbonFile(metadataPath) + .isFileExist(metadataPath, FileFactory.getFileType(metadataPath))) { + // If metadata folder exists, it is a transactional table + isTransactionalTable = true; } - }; - ThriftReader thriftReader = - new ThriftReader(CarbonTablePath.getSchemaFilePath(tablePath), createTBase); - thriftReader.open(); - org.apache.carbondata.format.TableInfo tableInfo = - (org.apache.carbondata.format.TableInfo) thriftReader.read(); - thriftReader.close(); - + } catch (IOException e) { + throw new RuntimeException(e); + } + org.apache.carbondata.format.TableInfo tableInfo; + if (isTransactionalTable) { + //Step 2: read the metadata (tableInfo) of the table. + ThriftReader.TBaseCreator createTBase = new ThriftReader.TBaseCreator() { + // TBase is used to read and write thrift objects. + // TableInfo is a kind of TBase used to read and write table information. + // TableInfo is generated by thrift, + // see schema.thrift under format/src/main/thrift for details. + public TBase create() { + return new org.apache.carbondata.format.TableInfo(); + } + }; + ThriftReader thriftReader = + new ThriftReader(CarbonTablePath.getSchemaFilePath(tablePath), createTBase); + thriftReader.open(); + tableInfo = (org.apache.carbondata.format.TableInfo) thriftReader.read(); + thriftReader.close(); + } else { + tableInfo = + CarbonUtil.inferSchema(tablePath, table.getTableName(), false, new Configuration()); --- End diff -- Is this code (tableInfo = CarbonUtil.inferSchema(tablePath, table.getTableName(), false, new Configuration());) tested on hdfs, FileSystem may be not created by "new Configuration()"
---