Codota Logo
Expression
Code IndexAdd Codota to your IDE (free)

How to use
Expression
in
org.h2.expression

Best Java code snippets using org.h2.expression.Expression (Showing top 20 results out of 315)

  • Common ways to obtain Expression
private void myMethod () {
Expression e =
  • Codota IconValueExpression.getNull()
  • Codota IconColumn column;column.getDefaultExpression()
  • Codota IconTableFilter tableFilter;tableFilter.getJoinCondition()
  • Smart code suggestions by Codota
}
origin: com.h2database/h2

/**
 * Get the column name or alias name of this expression.
 *
 * @return the column name
 */
public String getColumnName() {
  return getAlias();
}
origin: apache/ignite

/**
 * @param e Expression to take type from.
 * @return Type.
 */
public static GridSqlType fromExpression(Expression e) {
  if (e.getType() == Value.UNKNOWN)
    return UNKNOWN;
  return fromColumn(new Column(null, e.getType(), e.getPrecision(), e.getScale(), e.getDisplaySize()));
}
origin: com.h2database/h2

@Override
public Expression optimize(Session session) {
  Expression e2 = condition.getNotIfPossible(session);
  if (e2 != null) {
    return e2.optimize(session);
  }
  Expression expr = condition.optimize(session);
  if (expr.isConstant()) {
    Value v = expr.getValue(session);
    if (v == ValueNull.INSTANCE) {
      return ValueExpression.getNull();
    }
    return ValueExpression.get(v.convertTo(Value.BOOLEAN).negate());
  }
  condition = expr;
  return this;
}
origin: com.h2database/h2

@Override
public void prepare() {
  expression = expression.optimize(session);
  expressions = new Expression[] { expression };
  isResultSet = expression.getType() == Value.RESULT_SET;
  if (isResultSet) {
    prepareAlways = true;
  }
}
origin: com.h2database/h2

@Override
public Expression optimize(Session session) {
  left = left.optimize(session);
  if (left.isConstant() && left == ValueExpression.getNull()) {
    return left;
  }
  return this;
}
origin: com.h2database/h2

e = e.optimize(session);
args[i] = e;
if (!e.isConstant()) {
  allConst = false;
for (Expression e : args) {
  if (e != ValueExpression.getNull()) {
    int type = e.getType();
    if (type != Value.UNKNOWN && type != Value.NULL) {
      t = Value.getHigherOrder(t, type);
      s = Math.max(s, e.getScale());
      p = Math.max(p, e.getPrecision());
      d = Math.max(d, e.getDisplaySize());
  Expression then = args[i];
  if (then != ValueExpression.getNull()) {
    int type = then.getType();
    if (type != Value.UNKNOWN && type != Value.NULL) {
      t = Value.getHigherOrder(t, type);
      s = Math.max(s, then.getScale());
      p = Math.max(p, then.getPrecision());
      d = Math.max(d, then.getDisplaySize());
  Expression elsePart = args[args.length - 1];
  if (elsePart != ValueExpression.getNull()) {
    int type = elsePart.getType();
    if (type != Value.UNKNOWN && type != Value.NULL) {
      t = Value.getHigherOrder(t, type);
      s = Math.max(s, elsePart.getScale());
origin: com.h2database/h2

@Override
public Expression optimize(Session session) {
  left = left.optimize(session);
  boolean constant = left.isConstant();
  if (constant && left == ValueExpression.getNull()) {
    return left;
  for (int i = 0; i < size; i++) {
    Expression e = valueList.get(i);
    e = e.optimize(session);
    if (e.isConstant() && e.getValue(session) != ValueNull.INSTANCE) {
      allValuesNull = false;
    if (allValuesConstant && !e.isConstant()) {
      allValuesConstant = false;
    Expression right = valueList.get(0);
    Expression expr = new Comparison(session, Comparison.EQUAL, left, right);
    expr = expr.optimize(session);
    return expr;
    int leftType = left.getType();
    if (leftType == Value.UNKNOWN) {
      return this;
    expr = expr.optimize(session);
    return expr;
origin: com.h2database/h2

for (int i = 0; i < visibleColumnCount; i++) {
  Expression expr = expressions.get(i);
  expr = expr.getNonAliasExpression();
  String sql = expr.getSQL();
  expressionSQL.add(sql);
for (int i = 0; i < size; i++) {
  Expression expr = group.get(i);
  String sql = expr.getSQL();
  int found = -1;
  for (int j = 0; j < expSize; j++) {
      if (db.equalsIdentifiers(sql, e.getAlias())) {
        found = j;
        break;
      sql = expr.getAlias();
      if (db.equalsIdentifiers(sql, e.getAlias())) {
        found = j;
        break;
Expression expr = expressions.get(havingIndex);
SelectListColumnResolver res = new SelectListColumnResolver(this);
expr.mapColumns(res, 0);
origin: com.h2database/h2

  /**
   * Add an additional element if possible. Example: given two conditions
   * A IN(1, 2) OR A=3, the constant 3 is added: A IN(1, 2, 3).
   *
   * @param session the session
   * @param other the second condition
   * @return null if the condition was not added, or the new condition
   */
  Expression getAdditional(Session session, Comparison other) {
    Expression add = other.getIfEquals(left);
    if (add != null) {
      if (add.isConstant()) {
        valueList.add(add);
        valueSet.add(add.getValue(session).convertTo(left.getType()));
        return this;
      }
    }
    return null;
  }
}
origin: com.h2database/h2

left = left.optimize(session);
right = right.optimize(session);
int lc = left.getCost(), rc = right.getCost();
if (rc < lc) {
  Expression t = left;
        session, compRight, true);
    if (added != null) {
      added = added.optimize(session);
      return new ConditionAndOr(AND, this, added);
        session, compRight, false);
    if (added != null) {
      return added.optimize(session);
        getAdditional((Comparison) right);
    if (added != null) {
      return added.optimize(session);
        getAdditional((Comparison) left);
    if (added != null) {
      return added.optimize(session);
        getAdditional(session, (Comparison) right);
    if (added != null) {
      return added.optimize(session);
        getAdditional(session, (Comparison) left);
    if (added != null) {
origin: apache/ignite

return new GridSqlAlias(expression.getAlias(),
  parseExpression(expression.getNonAliasExpression(), calcTypes), true);
  new GridSqlConst(expression.getValue(null));
return new GridSqlOperation(NOT, parseExpression(expression.getNotIfPossible(null), calcTypes));
origin: com.h2database/h2

/**
 * Set the on update expression.
 *
 * @param session the session
 * @param onUpdateExpression the on update expression
 */
public void setOnUpdateExpression(Session session, Expression onUpdateExpression) {
  // also to test that no column names are used
  if (onUpdateExpression != null) {
    onUpdateExpression = onUpdateExpression.optimize(session);
    if (onUpdateExpression.isConstant()) {
      onUpdateExpression = ValueExpression.get(onUpdateExpression.getValue(session));
    }
  }
  this.onUpdateExpression = onUpdateExpression;
}
origin: com.h2database/h2

for (int i = 0; i < expressions.size(); i++) {
  Expression e = expressions.get(i);
  String proposedColumnName = e.getAlias();
  String columnName = columnNamer.getColumnName(e, i, proposedColumnName);
    e = new Alias(e, columnName, true);
  expressions.set(i, e.optimize(session));
  condition = condition.optimize(session);
  for (TableFilter f : filters) {
      condition.createIndexConditions(session, f);
    expressions.size() == 1 && condition == null) {
  Expression expr = expressions.get(0);
  expr = expr.getNonAliasExpression();
  if (expr instanceof ExpressionColumn) {
    Column column = ((ExpressionColumn) expr).getColumn();
origin: com.h2database/h2

@Override
public void prepare() {
  onCondition.addFilterConditions(sourceTableFilter, true);
  onCondition.addFilterConditions(targetTableFilter, true);
  onCondition.mapColumns(sourceTableFilter, 2);
  onCondition.mapColumns(targetTableFilter, 1);
  onCondition = onCondition.optimize(session);
  onCondition.createIndexConditions(session, sourceTableFilter);
  onCondition.createIndexConditions(session, targetTableFilter);
        Expression e = expr[i];
        if (e != null) {
          expr[i] = e.optimize(session);
  targetMatchCondition.addFilterConditions(sourceTableFilter, true);
  targetMatchCondition.mapColumns(sourceTableFilter, 2);
  targetMatchCondition = targetMatchCondition.optimize(session);
  targetMatchCondition.createIndexConditions(session, sourceTableFilter);
  targetMatchQuery.prepare();
origin: com.h2database/h2

private Long getLong(Expression expr) {
  if (expr == null) {
    return null;
  }
  return expr.optimize(session).getValue(session).getLong();
}
origin: com.h2database/h2

SelectListColumnResolver(Select select) {
  this.select = select;
  int columnCount = select.getColumnCount();
  columns = new Column[columnCount];
  expressions = new Expression[columnCount];
  ArrayList<Expression> columnList = select.getExpressions();
  ColumnNamer columnNamer= new ColumnNamer(select.getSession());
  for (int i = 0; i < columnCount; i++) {
    Expression expr = columnList.get(i);
    String columnName = columnNamer.getColumnName(expr, i, expr.getAlias());
    Column column = new Column(columnName, Value.NULL);
    column.setTable(null, i);
    columns[i] = column;
    expressions[i] = expr.getNonAliasExpression();
  }
}
origin: com.h2database/h2

/**
 * Get the current value of the expression.
 *
 * @param session the session
 * @return the value
 */
public Value getCurrentValue(Session session) {
  return expression.getValue(session);
}
origin: com.h2database/h2

Expression comp;
Expression col = expressions.get(columnId);
col = col.getNonAliasExpression();
if (col.isEverything(ExpressionVisitor.QUERY_COMPARABLE_VISITOR)) {
  comp = new Comparison(session, comparisonType, col, param);
} else {
comp = comp.optimize(session);
boolean addToCondition = true;
if (isGroupQuery) {
origin: com.h2database/h2

    } else if (tableAlias == null && db.equalsIdentifiers(col, ec.getAlias())) {
      found = true;
    } else {
      Expression ec2 = ec.getNonAliasExpression();
      if (ec2 instanceof ExpressionColumn) {
        ExpressionColumn c2 = (ExpressionColumn) ec2;
  String s = e.getSQL();
  if (expressionSQL != null) {
    for (int j = 0, size = expressionSQL.size(); j < size; j++) {
  if (mustBeInResult) {
    throw DbException.get(ErrorCode.ORDER_BY_NOT_IN_RESULT,
        e.getSQL());
  String sql = e.getSQL();
  expressionSQL.add(sql);
o.expression = expressions.get(idx).getNonAliasExpression();
origin: com.h2database/h2

if (columnName == null && columnExp.getAlias() != null && !DEFAULT_COLUMN_NAME.equals(columnExp.getAlias())) {
  columnName = columnExp.getAlias();
  if (!isAllowableColumnName(columnName)) {
    columnName = fixColumnName(columnName);
if (columnName == null && columnExp.getColumnName() != null
    && !DEFAULT_COLUMN_NAME.equals(columnExp.getColumnName())) {
  columnName = columnExp.getColumnName();
  if (!isAllowableColumnName(columnName)) {
    columnName = fixColumnName(columnName);
if (columnName == null && columnExp.getSQL() != null && !DEFAULT_COLUMN_NAME.equals(columnExp.getSQL())) {
  columnName = columnExp.getSQL();
  if (!isAllowableColumnName(columnName)) {
    columnName = fixColumnName(columnName);
org.h2.expressionExpression

Javadoc

An expression is a operation, a value, or a function in a query.

Most used methods

  • getAlias
    Get the alias name of a column or SQL expression if it is not an aliased expression.
  • getDisplaySize
    Get the display size of this expression.
  • getNonAliasExpression
    Returns the main expression, skipping aliases.
  • getNotIfPossible
    If it is possible, return the negated expression. This is used to optimize NOT expressions: NOT ID>1
  • getPrecision
    Get the precision of this expression.
  • getScale
    Get the scale of this expression.
  • getType
    Return the data type. The data type may not be known before the optimization phase.
  • getValue
    Return the resulting value for the current row.
  • isConstant
    Check if this expression will always return the same value.
  • addFilterConditions
    Add conditions to a table filter if they can be evaluated.
  • createIndexConditions
    Create index conditions if possible and attach them to the table filter.
  • getBooleanValue
    Get the value in form of a boolean expression. Returns true or false. In this database, everything c
  • createIndexConditions,
  • getBooleanValue,
  • getColumnName,
  • getCost,
  • getNullable,
  • getSQL,
  • getSchemaName,
  • getTableAlias,
  • getTableName,
  • isAutoIncrement

Popular in Java

  • Reactive rest calls using spring rest template
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
    Returns a stream for the resource with the specified name. See #getResource(String) for a descriptio
  • startActivity (Activity)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Kernel (java.awt.image)
  • StringTokenizer (java.util)
    The string tokenizer class allows an application to break a string into tokens. The tokenization met
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
  • JOptionPane (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now