Package net.sf.jsqlparser.schema

Examples of net.sf.jsqlparser.schema.Column


    public static void setUpClass() throws Exception {
        Table table = new Table();
        table.setName("ORDERS");
        List<Table> tableList = new ArrayList<Table>(Arrays.asList(table));

        _columnOrderdate = new Column();
        _columnOrderdate.setTable(table);
        _columnOrderdate.setColumnName("ORDERDATE");

        MinorThan mt = new MinorThan();
        mt.setLeftExpression(_columnOrderdate);
View Full Code Here


    }
   
    @Test
    public void testNameToColumn() {
        String name = "N1.NATIONNAME";
        Column column = ParserUtil.nameToColumn(name);   
        assertEquals(name, ParserUtil.getStringExpr(column));
    }
View Full Code Here

    toColumn.setColumnName(fromColumn.getColumnName());
    toColumn.setTable(fromColumn.getTable());
  }

  public static void copyColumn(Column toColumn, String fromColumnStr) {
    final Column fromColumn = nameToColumn(fromColumnStr);
    copyColumn(toColumn, fromColumn);
  }
View Full Code Here

   */
  public static String getComponentName(List<Column> columns) {
    // all the columns will be from the same table, so we can choose any of
    // them
    // (here we choose the first one)
    final Column column = columns.get(0);
    return getComponentName(column);
  }
View Full Code Here

    final String compName = nameParts[0];
    final String columnName = nameParts[1];

    final Table table = new Table();
    table.setAlias(compName);
    final Column column = new Column();
    column.setColumnName(columnName);
    column.setTable(table);
    return column;
  }
View Full Code Here

  public double estimate(AndExpression and) {
    // the case when we have the same single column on both sides
    final Expression leftExpr = and.getLeftExpression();
    final List<Column> leftColumns = ParserUtil.getJSQLColumns(leftExpr);
    final Column leftColumn = leftColumns.get(0);

    final Expression rightExpr = and.getRightExpression();
    final List<Column> rightColumns = ParserUtil.getJSQLColumns(rightExpr);
    final Column rightColumn = rightColumns.get(0);

    if (leftColumn.toString().equals(rightColumn.toString()))
      // not using leftExpr and rightExpr, because we want to preserve
      // type
      return 1 - (1 - estimate(and.getLeftExpression()))
          - (1 - estimate(and.getRightExpression()));
    else
View Full Code Here

  }

  public double estimate(EqualsTo equals) {
    final List<Column> columns = ParserUtil.getJSQLColumns(equals);

    final Column column = columns.get(0);
    final String fullSchemaColumnName = _tan.getFullSchemaColumnName(column);

    final long distinctValues = _schema.getNumDistinctValues(fullSchemaColumnName);
    return 1.0 / distinctValues;
  }
View Full Code Here

    return estimate(and);
  }

  public double estimate(MinorThan mt) {
    final List<Column> columns = ParserUtil.getJSQLColumns(mt);
    final Column column = columns.get(0);
    final TypeConversion tc = _schema.getType(ParserUtil.getFullSchemaColumnName(column, _tan));

    // TODO: assume uniform distribution
    final String fullSchemaColumnName = _tan.getFullSchemaColumnName(column);
    Object minValue = _schema.getRange(fullSchemaColumnName).getMin();
View Full Code Here

        //expected results
        Table tableN1 = new Table(); tableN1.setName("N1");
        Table tableN2 = new Table(); tableN2.setName("N2");
        Table tableLineitem = new Table(); tableLineitem.setName("LINEITEM");
       
        Column se1 = new Column(); se1.setTable(tableN1); se1.setColumnName("NAME");
        Column se2 = new Column(); se2.setTable(tableN2); se2.setColumnName("NAME");
        Column ls = new Column(); ls.setTable(tableLineitem); ls.setColumnName("SHIPDATE");
        ExpressionList el = new ExpressionList();
        el.setExpressions(Arrays.asList(ls));
        Function se3 = new Function(); se3.setName("EXTRACT_YEAR"); se3.setParameters(el);
        Column le = new Column(); le.setTable(tableLineitem); le.setColumnName("EXTENDEDPRICE");
        Column ld = new Column(); ld.setTable(tableLineitem); ld.setColumnName("DISCOUNT");
        Subtraction diff = new Subtraction(); diff.setLeftExpression(new DoubleValue("1.0")); diff.setRightExpression(ld);
        Parenthesis diffPnths = new Parenthesis();diffPnths.setExpression(diff);
        Multiplication se4 = new Multiplication(); se4.setLeftExpression(le); se4.setRightExpression(diffPnths);
        List<Expression> expListExpr = Arrays.asList(se1, se2, se3, se4);
       
View Full Code Here

   */
  private List<String> getAloneColumnNames(List<Expression> exprList) {
    final List<String> result = new ArrayList<String>();
    for (final Expression expr : exprList)
      if (expr instanceof Column) {
        final Column column = (Column) expr;
        result.add(ParserUtil.getStringExpr(column));
      }
    return result;
  }
View Full Code Here

TOP

Related Classes of net.sf.jsqlparser.schema.Column

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.