Search in sources :

Example 11 with VoltXMLElement

use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.

the class AbstractParsedStmt method parseVectorExpression.

/**
     * Parse a Vector value for SQL-IN
     */
private AbstractExpression parseVectorExpression(VoltXMLElement exprNode) {
    ArrayList<AbstractExpression> args = new ArrayList<>();
    for (VoltXMLElement argNode : exprNode.children) {
        assert (argNode != null);
        // recursively parse each argument subtree (could be any kind of expression).
        AbstractExpression argExpr = parseExpressionNode(argNode);
        assert (argExpr != null);
        args.add(argExpr);
    }
    VectorValueExpression vve = new VectorValueExpression();
    vve.setValueType(VoltType.VOLTTABLE);
    vve.setArgs(args);
    return vve;
}
Also used : VectorValueExpression(org.voltdb.expressions.VectorValueExpression) AbstractExpression(org.voltdb.expressions.AbstractExpression) ArrayList(java.util.ArrayList) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement)

Example 12 with VoltXMLElement

use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.

the class TestDDLCompiler method testTooManyColumnTable.

//
// Note, this should succeed as HSQL doesn't have a hard limit
// on the number of columns. The test in TestVoltCompiler will
// fail on 1025 columns.
// @throws HSQLParseException
//
public void testTooManyColumnTable() throws IOException, HSQLParseException {
    String schemaPath = "";
    URL url = TestVoltCompiler.class.getResource("toowidetable-ddl.sql");
    schemaPath = URLDecoder.decode(url.getPath(), "UTF-8");
    FileReader fr = new FileReader(new File(schemaPath));
    BufferedReader br = new BufferedReader(fr);
    String ddl1 = "";
    String line;
    while ((line = br.readLine()) != null) {
        ddl1 += line + "\n";
    }
    br.close();
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    hsql.runDDLCommand(ddl1);
    VoltXMLElement xml = hsql.getXMLFromCatalog();
    System.out.println(xml);
    assertTrue(xml != null);
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement) File(java.io.File) URL(java.net.URL)

Example 13 with VoltXMLElement

use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.

the class TestDDLCompiler method testSimpleDDLCompiler.

public void testSimpleDDLCompiler() throws HSQLParseException {
    String ddl1 = "CREATE TABLE warehouse ( " + "w_id integer default '0' NOT NULL, " + "w_name varchar(16) default NULL, " + "w_street_1 varchar(32) default NULL, " + "w_street_2 varchar(32) default NULL, " + "w_city varchar(32) default NULL, " + "w_state varchar(2) default NULL, " + "w_zip varchar(9) default NULL, " + "w_tax float default NULL, " + "PRIMARY KEY  (w_id) " + ");";
    HSQLInterface hsql = HSQLInterface.loadHsqldb();
    hsql.runDDLCommand(ddl1);
    VoltXMLElement xml = hsql.getXMLFromCatalog();
    System.out.println(xml);
    assertTrue(xml != null);
}
Also used : HSQLInterface(org.hsqldb_voltpatches.HSQLInterface) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement)

Example 14 with VoltXMLElement

use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.

the class VoltXMLElementHelper method buildLimitElements.

// Build VoltXMLElement for expression like "LIMIT 1".
public static List<VoltXMLElement> buildLimitElements(int limit, String limitValueElementId) {
    if (limitValueElementId == null) {
        return null;
    }
    List<VoltXMLElement> retval = new ArrayList<VoltXMLElement>();
    retval.add(new VoltXMLElement("offset"));
    VoltXMLElement limitElement = new VoltXMLElement("limit");
    String strLimit = String.valueOf(limit);
    limitElement.attributes.put("limit", strLimit);
    limitElement.children.add(buildValueElement(limitValueElementId, false, strLimit, "BIGINT"));
    retval.add(limitElement);
    return retval;
}
Also used : ArrayList(java.util.ArrayList) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement)

Example 15 with VoltXMLElement

use of org.hsqldb_voltpatches.VoltXMLElement in project voltdb by VoltDB.

the class DRTable method processStatement.

@Override
protected boolean processStatement(DDLStatement ddlStatement, Database db, DdlProceduresToLoad whichProcs) throws VoltCompilerException {
    // matches if it is DR TABLE <table-name> [DISABLE]
    // group 1 -- table name
    // group 2 -- NULL: enable dr
    //            NOT NULL: disable dr
    // TODO: maybe I should write one fit all regex for this.
    Matcher statementMatcher = SQLParser.matchDRTable(ddlStatement.statement);
    if (!statementMatcher.matches()) {
        return false;
    }
    String tableName;
    if (statementMatcher.group(1).equalsIgnoreCase("*")) {
        tableName = "*";
    } else {
        tableName = checkIdentifierStart(statementMatcher.group(1), ddlStatement.statement);
    }
    //System.out.println("\n\n" + m_schema.toString());
    VoltXMLElement tableXML = m_schema.findChild("table", tableName.toUpperCase());
    if (tableXML != null) {
        if (tableXML.attributes.containsKey("export")) {
            throw m_compiler.new VoltCompilerException(String.format("Invalid DR statement: table %s is an export table", tableName));
        } else {
            if ((statementMatcher.group(2) != null)) {
                tableXML.attributes.put("drTable", "DISABLE");
            } else {
                tableXML.attributes.put("drTable", "ENABLE");
            }
        }
    } else {
        throw m_compiler.new VoltCompilerException(String.format("While configuring dr, table %s was not present in the catalog.", tableName));
    }
    return true;
}
Also used : Matcher(java.util.regex.Matcher) VoltXMLElement(org.hsqldb_voltpatches.VoltXMLElement) VoltCompilerException(org.voltdb.compiler.VoltCompiler.VoltCompilerException)

Aggregations

VoltXMLElement (org.hsqldb_voltpatches.VoltXMLElement)62 AbstractExpression (org.voltdb.expressions.AbstractExpression)14 Constraint (org.voltdb.catalog.Constraint)13 VoltCompilerException (org.voltdb.compiler.VoltCompiler.VoltCompilerException)10 ArrayList (java.util.ArrayList)9 VoltType (org.voltdb.VoltType)7 TupleValueExpression (org.voltdb.expressions.TupleValueExpression)6 HSQLInterface (org.hsqldb_voltpatches.HSQLInterface)5 VoltXMLDiff (org.hsqldb_voltpatches.VoltXMLElement.VoltXMLDiff)5 Column (org.voltdb.catalog.Column)5 Table (org.voltdb.catalog.Table)5 Matcher (java.util.regex.Matcher)4 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3 HSQLParseException (org.hsqldb_voltpatches.HSQLInterface.HSQLParseException)3 JSONException (org.json_voltpatches.JSONException)3 Index (org.voltdb.catalog.Index)3 Statement (org.voltdb.catalog.Statement)3 StmtSubqueryScan (org.voltdb.planner.parseinfo.StmtSubqueryScan)3 ExpressionType (org.voltdb.types.ExpressionType)3