mirror of https://github.com/apache/druid.git
Don't fail on invalid views in InformationSchema (#10960)
* Don't fail on invalid views in InformationSchema * Fix test
This commit is contained in:
parent
7f96ca8f5e
commit
9c083783c9
|
@ -46,6 +46,7 @@ import org.apache.calcite.schema.TableMacro;
|
|||
import org.apache.calcite.schema.impl.AbstractSchema;
|
||||
import org.apache.calcite.schema.impl.AbstractTable;
|
||||
import org.apache.calcite.sql.type.SqlTypeName;
|
||||
import org.apache.druid.java.util.emitter.EmittingLogger;
|
||||
import org.apache.druid.segment.column.RowSignature;
|
||||
import org.apache.druid.segment.column.ValueType;
|
||||
import org.apache.druid.server.security.AuthenticationResult;
|
||||
|
@ -64,6 +65,8 @@ import java.util.Set;
|
|||
|
||||
public class InformationSchema extends AbstractSchema
|
||||
{
|
||||
private static final EmittingLogger log = new EmittingLogger(InformationSchema.class);
|
||||
|
||||
private static final String CATALOG_NAME = "druid";
|
||||
private static final String SCHEMATA_TABLE = "SCHEMATA";
|
||||
private static final String TABLES_TABLE = "TABLES";
|
||||
|
@ -357,12 +360,18 @@ public class InformationSchema extends AbstractSchema
|
|||
return null;
|
||||
}
|
||||
|
||||
return generateColumnMetadata(
|
||||
schemaName,
|
||||
functionName,
|
||||
viewMacro.apply(ImmutableList.of()),
|
||||
typeFactory
|
||||
);
|
||||
try {
|
||||
return generateColumnMetadata(
|
||||
schemaName,
|
||||
functionName,
|
||||
viewMacro.apply(ImmutableList.of()),
|
||||
typeFactory
|
||||
);
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e, "Encountered exception while handling view[%s].", functionName);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -830,6 +830,12 @@ public class BaseCalciteQueryTest extends CalciteTestBase
|
|||
"restrictedView",
|
||||
"SELECT __time, dim1, dim2, m1 FROM druid.forbiddenDatasource WHERE dim2 = 'a'"
|
||||
);
|
||||
|
||||
viewManager.createView(
|
||||
plannerFactory,
|
||||
"invalidView",
|
||||
"SELECT __time, dim1, dim2, m1 FROM druid.invalidDatasource WHERE dim2 = 'a'"
|
||||
);
|
||||
return sqlLifecycleFactory;
|
||||
}
|
||||
|
||||
|
|
|
@ -889,6 +889,7 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
|||
.add(new Object[]{"view", "bview", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "cview", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "dview", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "invalidView", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "restrictedView", "VIEW", "NO", "NO"})
|
||||
.build()
|
||||
);
|
||||
|
@ -924,6 +925,7 @@ public class CalciteQueryTest extends BaseCalciteQueryTest
|
|||
.add(new Object[]{"view", "cview", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "dview", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "forbiddenView", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "invalidView", "VIEW", "NO", "NO"})
|
||||
.add(new Object[]{"view", "restrictedView", "VIEW", "NO", "NO"})
|
||||
.build()
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue