Search in sources :

Example 1 with LongLiteral

use of io.crate.sql.tree.LongLiteral in project crate by crate.

the class AstBuilder method visitMaybeParametrizedDataType.

@Override
public Node visitMaybeParametrizedDataType(SqlBaseParser.MaybeParametrizedDataTypeContext context) {
    StringLiteral name = (StringLiteral) visit(context.baseDataType());
    var parameters = new ArrayList<Integer>(context.integerLiteral().size());
    for (var param : context.integerLiteral()) {
        var literal = visit(param);
        int val;
        if (literal instanceof LongLiteral) {
            val = Math.toIntExact(((LongLiteral) literal).getValue());
        } else {
            val = ((IntegerLiteral) literal).getValue();
        }
        parameters.add(val);
    }
    return new ColumnType<>(name.getValue(), parameters);
}
Also used : ObjectColumnType(io.crate.sql.tree.ObjectColumnType) CollectionColumnType(io.crate.sql.tree.CollectionColumnType) ColumnType(io.crate.sql.tree.ColumnType) EscapedCharStringLiteral(io.crate.sql.tree.EscapedCharStringLiteral) StringLiteral(io.crate.sql.tree.StringLiteral) LongLiteral(io.crate.sql.tree.LongLiteral) ArrayList(java.util.ArrayList) IndexColumnConstraint(io.crate.sql.tree.IndexColumnConstraint) CheckConstraint(io.crate.sql.tree.CheckConstraint) NotNullColumnConstraint(io.crate.sql.tree.NotNullColumnConstraint) PrimaryKeyColumnConstraint(io.crate.sql.tree.PrimaryKeyColumnConstraint) ColumnConstraint(io.crate.sql.tree.ColumnConstraint) DropCheckConstraint(io.crate.sql.tree.DropCheckConstraint) CheckColumnConstraint(io.crate.sql.tree.CheckColumnConstraint) PrimaryKeyConstraint(io.crate.sql.tree.PrimaryKeyConstraint)

Aggregations

CheckColumnConstraint (io.crate.sql.tree.CheckColumnConstraint)1 CheckConstraint (io.crate.sql.tree.CheckConstraint)1 CollectionColumnType (io.crate.sql.tree.CollectionColumnType)1 ColumnConstraint (io.crate.sql.tree.ColumnConstraint)1 ColumnType (io.crate.sql.tree.ColumnType)1 DropCheckConstraint (io.crate.sql.tree.DropCheckConstraint)1 EscapedCharStringLiteral (io.crate.sql.tree.EscapedCharStringLiteral)1 IndexColumnConstraint (io.crate.sql.tree.IndexColumnConstraint)1 LongLiteral (io.crate.sql.tree.LongLiteral)1 NotNullColumnConstraint (io.crate.sql.tree.NotNullColumnConstraint)1 ObjectColumnType (io.crate.sql.tree.ObjectColumnType)1 PrimaryKeyColumnConstraint (io.crate.sql.tree.PrimaryKeyColumnConstraint)1 PrimaryKeyConstraint (io.crate.sql.tree.PrimaryKeyConstraint)1 StringLiteral (io.crate.sql.tree.StringLiteral)1 ArrayList (java.util.ArrayList)1