ConcreteTableNode(String alias, TableName name) { super(SchemaUtil.normalizeIdentifier(alias)); this.name = name; }
FunctionParseNode(String name, List<ParseNode> children, BuiltInFunctionInfo info) { super(children); this.name = SchemaUtil.normalizeIdentifier(name); this.info = info; }
public PNormalizedName(String nonNormalizedName) { super(SchemaUtil.normalizeIdentifier(nonNormalizedName)); }
public boolean isCountFunction(String field) { return CountAggregateFunction.NORMALIZED_NAME.equals(SchemaUtil.normalizeIdentifier(field)); }
public static TableName createNormalized(String schemaName, String tableName) { schemaName = schemaName == null ? null : SchemaUtil.normalizeIdentifier(schemaName); tableName = SchemaUtil.normalizeIdentifier(tableName); return new TableName(schemaName, tableName); }
ColumnFamilyDef(String name, List<ColumnDef> columnDefs, Map<String,Object> props) { this.name = SchemaUtil.normalizeIdentifier(name); this.columnDefs = ImmutableList.copyOf(columnDefs); this.props = props == null ? Collections.<String,Object>emptyMap() : props; }
public int getColumnIndex(String name) throws SQLException { if (!someCaseSensitive) { name = SchemaUtil.normalizeIdentifier(name); } Integer index = reverseIndex.get(name); if (index == null) { if (!allCaseSensitive && someCaseSensitive) { name = SchemaUtil.normalizeIdentifier(name); index = reverseIndex.get(name); } if (index == null) { throw new ColumnNotFoundException(name); } } return index; }
PropertyName(String familyName, String propertyName) { this.familyName = familyName == null ? null : new NamedNode(familyName); this.propertyName = SchemaUtil.normalizeIdentifier(propertyName);; }
public FunctionParseNode functionDistinct(String name, List<ParseNode> args) { if (CountAggregateFunction.NAME.equals(SchemaUtil.normalizeIdentifier(name))) { BuiltInFunctionInfo info = getInfo( SchemaUtil.normalizeIdentifier(DistinctCountAggregateFunction.NAME), args); return new DistinctCountParseNode(name, args, info); } else { throw new UnsupportedOperationException("DISTINCT not supported with " + name); } }
public AliasedNode(String alias, ParseNode node) { this.isCaseSensitve = alias != null && SchemaUtil.isCaseSensitive(alias); this.alias = alias == null ? null : SchemaUtil.normalizeIdentifier(alias); this.node = node; }
NamedNode(String name) { this.name = SchemaUtil.normalizeIdentifier(name); this.isCaseSensitive = name == null ? false : SchemaUtil.isCaseSensitive(name); }
private static BuiltInFunctionInfo getInfo(String name, List<ParseNode> children) { return get(SchemaUtil.normalizeIdentifier(name), children); }
@Override public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException { // Catalogs are not supported for schemas if (catalog != null && catalog.length() > 0) { return emptyResultSet; } StringBuilder buf = new StringBuilder("select /*+" + Hint.NO_INTRA_REGION_PARALLELIZATION + "*/ distinct " + "null " + TABLE_CATALOG_NAME + "," + // no catalog for tables TABLE_SCHEM_NAME + " from " + TYPE_SCHEMA_AND_TABLE + " where " + COLUMN_NAME + " is null"); if (schemaPattern != null) { buf.append(" and " + TABLE_SCHEM_NAME + " like '" + SchemaUtil.normalizeIdentifier(schemaPattern) + "'"); } Statement stmt = connection.createStatement(); return stmt.executeQuery(buf.toString()); }
private int addToColumnMetadataInfo(final List<String> columns , final Map<String,Integer> allColumnsInfoMap, int position) throws SQLException { Preconditions.checkNotNull(columns); Preconditions.checkNotNull(allColumnsInfoMap); for (int i = 0 ; i < columns.size() ; i++) { String columnName = SchemaUtil.normalizeIdentifier(columns.get(i).trim()); Integer sqlType = allColumnsInfoMap.get(columnName); if (sqlType == null) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.COLUMN_NOT_FOUND) .setColumnName(columnName).setTableName(this.fullTableName).build().buildException(); } else { columnMetadata[position] = new ColumnInfo(columnName, sqlType); position++; } } return position; }
public final String prop_name() throws RecognitionException { String ret = null; String p =null; try { // PhoenixSQL.g:510:5: (p= identifier ) // PhoenixSQL.g:510:9: p= identifier { pushFollow(FOLLOW_identifier_in_prop_name2462); p=identifier(); state._fsp--; if (state.failed) return ret; if ( state.backtracking==0 ) {ret = SchemaUtil.normalizeIdentifier(p); } } } catch (RecognitionException re) { throw re; } finally { // do for sure before leaving } return ret; } // $ANTLR end "prop_name"
private void assertColumnMetaData(ResultSet rs, String schema, String table, String column) throws SQLException { assertEquals(schema, rs.getString("TABLE_SCHEM")); assertEquals(table, rs.getString("TABLE_NAME")); assertEquals(SchemaUtil.normalizeIdentifier(column), rs.getString("COLUMN_NAME")); } }
@Test public void testOnlyNullInScanKey() throws Exception { // Select columns in PK String query = "select val from ptsdb where inst is null"; List<Object> binds = Collections.emptyList(); Scan scan = compileQuery(query, binds); // Projects column family with not null column assertEquals(1,scan.getFamilyMap().keySet().size()); assertArrayEquals(Bytes.toBytes(SchemaUtil.normalizeIdentifier(QueryConstants.DEFAULT_COLUMN_FAMILY)), scan.getFamilyMap().keySet().iterator().next()); }
@Test public void testNullInScanKey() throws Exception { // Select columns in PK String query = "select val from ptsdb where inst is null and host='a'"; List<Object> binds = Collections.emptyList(); Scan scan = compileQuery(query, binds); // Projects column family with not null column assertNull(scan.getFilter()); assertEquals(1,scan.getFamilyMap().keySet().size()); assertArrayEquals(Bytes.toBytes(SchemaUtil.normalizeIdentifier(QueryConstants.DEFAULT_COLUMN_FAMILY)), scan.getFamilyMap().keySet().iterator().next()); }
BuiltInFunctionInfo(Class<? extends FunctionExpression> f, BuiltInFunction d) { this.name = SchemaUtil.normalizeIdentifier(d.name()); this.funcCtor = d.nodeClass() == FunctionParseNode.class ? getExpressionCtor(f) : null; this.nodeCtor = d.nodeClass() == FunctionParseNode.class ? null : getParseNodeCtor(d.nodeClass()); this.args = new BuiltInFunctionArgInfo[d.args().length]; int requiredArgCount = 0; for (int i = 0; i < args.length; i++) { this.args[i] = new BuiltInFunctionArgInfo(d.args()[i]); if (requiredArgCount < i && this.args[i].getDefaultValue() != null) { requiredArgCount = i; } } this.requiredArgCount = requiredArgCount; this.isAggregate = AggregateFunction.class.isAssignableFrom(f); }
@Override public ParseNode visit(ColumnParseNode node) throws SQLException { if (useFullNameForAlias && node.getAlias() != null && node.getTableName() != null && SchemaUtil.normalizeIdentifier(node.getAlias()).equals(node.getName())) { node = NODE_FACTORY.column(NODE_FACTORY.table(node.getSchemaName(), node.getTableName()), node.isCaseSensitive() ? '"' + node.getName() + '"' : node.getName(), node.getFullName()); } return super.visit(node); } }