// We should find the Materialize node before the Insert
if (node instanceof MaterializePlanNode) {
for (Integer column_guid : node.getOutputColumnGUIDs()) {
PlanColumn column = PlannerContext.singleton().get(column_guid);
assert (column != null);
AbstractExpression exp = column.getExpression();
// Now extract the CatalogType objects that are being
// referenced by this materialization column
final List<CatalogType> catalog_refs = new ArrayList<CatalogType>();
new ExpressionTreeWalker() {
@Override
protected void callback(AbstractExpression exp) {
if (!(exp instanceof AbstractValueExpression))
return;
CatalogType element = null;
switch (exp.getExpressionType()) {
case VALUE_PARAMETER: {
int param_idx = ((ParameterValueExpression) exp).getParameterId();
element = catalog_stmt.getParameters().get(param_idx);
if (element == null) {
LOG.warn("ERROR: Unable to find Parameter object in catalog [" + ((ParameterValueExpression) exp).getParameterId() + "]");
this.stop();
}
// We want to use the ProcParameter instead of the StmtParameter
// It's not an error if the StmtParameter is not mapped to a
// ProcParameter
if (convert_params && ((StmtParameter) element).getProcparameter() != null) {
LOG.debug(element + "(" + element + ") --> ProcParameter[" + element.getField("procparameter") + "]");
element = ((StmtParameter) element).getProcparameter();
}
break;
}
case VALUE_TUPLE_ADDRESS:
case VALUE_TUPLE: {
// This shouldn't happen, but it is nice
// to be told if it does...
LOG.warn("Unexpected " + exp.getClass().getSimpleName() + " node when examining " + node.getClass().getSimpleName() + " for " + catalog_stmt);
break;
}
default: {
// Do nothing...
}