@Override public String getExpressionStr() { return getDelegate().getExpressionStr(); }
public static String getIndexColumnExpressionStr(PColumn col) { return col.getExpressionStr() == null ? IndexUtil.getCaseSensitiveDataColumnFullName(col.getName().getString()) : col.getExpressionStr(); }
String indexColName = col.getName().getString(); String dataColName = StringUtil.escapeBackslash(col.getExpressionStr()); dataColumns.append(dataColName).append(","); indexColumns.append('"').append(indexColName).append("\",");
colUpsert.setShort(17, keySeq); if (column.getExpressionStr() == null) { colUpsert.setNull(18, Types.VARCHAR); } else { colUpsert.setString(18, column.getExpressionStr());
@Test public void testNullAlterTableDefaultRemoved() throws Exception { String ddl = "CREATE TABLE table_with_default (" + "pk INTEGER PRIMARY KEY)"; String ddl2 = "ALTER TABLE table_with_default " + "ADD v CHAR(3) DEFAULT null"; Connection conn = DriverManager.getConnection(getUrl()); conn.createStatement().execute(ddl); conn.createStatement().execute(ddl2); PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache() .getTableRef(new PTableKey(null,"TABLE_WITH_DEFAULT")).getTable(); assertNull(table.getColumnForColumnName("V").getExpressionStr()); }
@Test public void testNullDefaultRemoved() throws Exception { String ddl = "CREATE TABLE table_with_default (" + "pk INTEGER PRIMARY KEY, " + "v VARCHAR DEFAULT null)"; Connection conn = DriverManager.getConnection(getUrl()); conn.createStatement().execute(ddl); PTable table = conn.unwrap(PhoenixConnection.class).getMetaDataCache() .getTableRef(new PTableKey(null,"TABLE_WITH_DEFAULT")).getTable(); assertNull(table.getColumnForColumnName("V").getExpressionStr()); }
PColumn newColumn = new PColumnImpl(oldColumn.getName(), oldColumn.getFamilyName(), oldColumn.getDataType(), oldColumn.getMaxLength(), oldColumn.getScale(), oldColumn.isNullable(), i-1+positionOffset, oldColumn.getSortOrder(), oldColumn.getArraySize(), oldColumn.getViewConstant(), oldColumn.isViewReferenced(), oldColumn.getExpressionStr(), oldColumn.isRowTimestamp(), oldColumn.isDynamic(), oldColumn.getColumnQualifierBytes(), oldColumn.getTimestamp()); columns.add(newColumn);
: new KeyValueColumnExpression(column, displayName); if (column.getExpressionStr() != null) { String url = PhoenixRuntime.JDBC_PROTOCOL + PhoenixRuntime.JDBC_PROTOCOL_SEPARATOR ParseNode defaultParseNode = new SQLParser(column.getExpressionStr()).parseExpression(); Expression defaultExpression = defaultParseNode.accept(compiler); if (!ExpressionUtil.isNull(defaultExpression, new ImmutableBytesWritable())) {
public PColumnImpl(PColumn column, byte[] viewConstant, boolean isViewReferenced) { this(column.getName(), column.getFamilyName(), column.getDataType(), column.getMaxLength(), column.getScale(), column.isNullable(), column.getPosition(), column.getSortOrder(), column.getArraySize(), viewConstant, isViewReferenced, column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(), column.getTimestamp(), column.isDerived()); }
public PColumnImpl(PColumn column, boolean derivedColumn, int position, byte[] viewConstant) { this(column.getName(), column.getFamilyName(), column.getDataType(), column.getMaxLength(), column.getScale(), column.isNullable(), position, column.getSortOrder(), column.getArraySize(), viewConstant, column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(), column.getTimestamp(), derivedColumn); }
public static PColumn getIndexPKColumn(int position, PColumn dataColumn) { assert (SchemaUtil.isPKColumn(dataColumn)); PName indexColumnName = PNameFactory.newName(getIndexColumnName(null, dataColumn.getName().getString())); PColumn column = new PColumnImpl(indexColumnName, null, dataColumn.getDataType(), dataColumn.getMaxLength(), dataColumn.getScale(), dataColumn.isNullable(), position, dataColumn.getSortOrder(), dataColumn.getArraySize(), null, false, dataColumn.getExpressionStr(), dataColumn.isRowTimestamp(), false, // TODO set the columnQualifierBytes correctly /*columnQualifierBytes*/null, HConstants.LATEST_TIMESTAMP); return column; }
public static ColumnResolver getResolverForCompiledDerivedTable(PhoenixConnection connection, TableRef tableRef, RowProjector projector) throws SQLException { List<PColumn> projectedColumns = new ArrayList<PColumn>(); PTable table = tableRef.getTable(); for (PColumn column : table.getColumns()) { Expression sourceExpression = projector.getColumnProjector(column.getPosition()).getExpression(); PColumnImpl projectedColumn = new PColumnImpl(column.getName(), column.getFamilyName(), sourceExpression.getDataType(), sourceExpression.getMaxLength(), sourceExpression.getScale(), sourceExpression.isNullable(), column.getPosition(), sourceExpression.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(), column.getTimestamp()); projectedColumns.add(projectedColumn); } PTable t = PTableImpl.builderWithColumns(table, projectedColumns) .build(); return new SingleTableColumnResolver(connection, new TableRef(tableRef.getTableAlias(), t, tableRef.getLowerBoundTimeStamp(), tableRef.hasDynamicCols())); }
if (!columnsBeingSet.get(i) && !column.isNullable() && column.getExpressionStr() == null) { throw new ConstraintViolationException(SchemaUtil.getColumnDisplayName(column) + " may not be null"); for (int i = posOffset + nValuesToSet; i < table.getColumns().size(); i++) { PColumn column = table.getColumns().get(i); if (!column.isNullable() && column.getExpressionStr() == null) { throw new ConstraintViolationException(SchemaUtil.getColumnDisplayName(column) + " may not be null");
if (column.getExpressionStr() != null) { nValues++; if (column.getExpressionStr() != null) { try { String url = PhoenixRuntime.JDBC_PROTOCOL new SQLParser(column.getExpressionStr()).parseExpression(); Expression defaultExpression = defaultParseNode.accept(compiler); defaultExpression.evaluate(null, key); + column.getName().getString() + " failed to compile default value expression of " + column.getExpressionStr());
throw new ConstraintViolationException(name.getString() + "." + column.getName().getString() + " may not be null"); } else if (isNull && PTableImpl.this.isImmutableRows() && column.getExpressionStr() == null) { } else if (isNull && !getStoreNulls() && !this.hasOnDupKey && column.getExpressionStr() == null) {
colName = ColumnName.caseSensitiveColumnName(IndexUtil.getIndexColumnName(columnFamilyName, column.getName().getString())); isRowTimestamp = column.isRowTimestamp(); if (colRef.getColumn().getExpressionStr() != null) { expressionStr = colRef.getColumn().getExpressionStr(); columnDefs.add(FACTORY.columnDef(colName, col.getDataType().getSqlTypeName(), col.isNullable(), col.getMaxLength(), col.getScale(), false, col.getSortOrder(), col.getExpressionStr(), col.isRowTimestamp()));
if (column.getExpressionStr() != null) { builder.setExpression(column.getExpressionStr());
public static PColumn getIndexPKColumn(int position, PColumn dataColumn) { assert (SchemaUtil.isPKColumn(dataColumn)); PName indexColumnName = PNameFactory.newName(getIndexColumnName(null, dataColumn.getName().getString())); PColumn column = new PColumnImpl(indexColumnName, null, dataColumn.getDataType(), dataColumn.getMaxLength(), dataColumn.getScale(), dataColumn.isNullable(), position, dataColumn.getSortOrder(), dataColumn.getArraySize(), null, false, dataColumn.getExpressionStr(), dataColumn.isRowTimestamp(), false, // TODO set the columnQualifierBytes correctly /*columnQualifierBytes*/null, HConstants.LATEST_TIMESTAMP); return column; }
public PColumnImpl(PColumn column, int position) { this(column.getName(), column.getFamilyName(), column.getDataType(), column.getMaxLength(), column.getScale(), column.isNullable(), position, column.getSortOrder(), column.getArraySize(), column.getViewConstant(), column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes()); }
public PColumnImpl(PColumn column, boolean derivedColumn, int position, byte[] viewConstant) { this(column.getName(), column.getFamilyName(), column.getDataType(), column.getMaxLength(), column.getScale(), column.isNullable(), position, column.getSortOrder(), column.getArraySize(), viewConstant, column.isViewReferenced(), column.getExpressionStr(), column.isRowTimestamp(), column.isDynamic(), column.getColumnQualifierBytes(), column.getTimestamp(), derivedColumn); }