lfyzjck commented on issue #2757:
URL: 
https://github.com/apache/incubator-doris/issues/2757#issuecomment-647297399


   Presto raise TableNotFoundException because it could not found any valid 
columns from Doris.
   
   I just found that the way Doris stored dataType is different with MySQL in 
`information_schema.columns` where Presto get table schema from.
   
   Doris:
   
![image](https://user-images.githubusercontent.com/800042/84974187-56833f80-b155-11ea-98d5-e4447f146905.png)
   
   MySQL:
   
![image](https://user-images.githubusercontent.com/800042/84974203-60a53e00-b155-11ea-9251-107ea5420012.png)
   
   The key is that dataType size is stored in other columns in MySQL.
   
   in Presto BaseJdbcClient.java
   ```
   public List<JdbcColumnHandle> getColumns(ConnectorSession session, 
JdbcTableHandle tableHandle)
       {
           try (Connection connection = 
connectionFactory.openConnection(JdbcIdentity.from(session))) {
               try (ResultSet resultSet = getColumns(tableHandle, 
connection.getMetaData())) {
                   List<JdbcColumnHandle> columns = new ArrayList<>();
                   while (resultSet.next()) {
                       JdbcTypeHandle typeHandle = new JdbcTypeHandle(
                               resultSet.getInt("DATA_TYPE"),
                               resultSet.getInt("COLUMN_SIZE"),
                               resultSet.getInt("DECIMAL_DIGITS"));
                       Optional<ReadMapping> columnMapping = 
toPrestoType(session, typeHandle);
                       // skip unsupported column types
                       if (columnMapping.isPresent()) {
                           String columnName = 
resultSet.getString("COLUMN_NAME");
                           boolean nullable = columnNullable == 
resultSet.getInt("NULLABLE");
                           columns.add(new JdbcColumnHandle(connectorId, 
columnName, typeHandle, columnMapping.get().getType(), nullable));
                       }
                   }
                   if (columns.isEmpty()) {
                       // In rare cases (e.g. PostgreSQL) a table might have no 
columns.
                       throw new 
TableNotFoundException(tableHandle.getSchemaTableName());
                   }
                   return ImmutableList.copyOf(columns);
               }
           }
           catch (SQLException e) {
               throw new PrestoException(JDBC_ERROR, e);
           }
       }
   ```


----------------------------------------------------------------
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:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to