Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fe/src/com/baidu/palo/analysis/Analyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ public List<Expr> getEqJoinConjuncts(TupleId id, TableRef rhsRef) {
List<ExprId> ojClauseConjuncts = null;
if (rhsRef != null) {
Preconditions.checkState(rhsRef.getJoinOp().isOuterJoin());
ojClauseConjuncts = globalState.conjunctsByOjClause.get(rhsRef);
ojClauseConjuncts = globalState.conjunctsByOjClause.get(rhsRef.getId());
}
for (ExprId conjunctId : conjunctIds) {
Expr e = globalState.conjuncts.get(conjunctId);
Expand Down
8 changes: 7 additions & 1 deletion fe/src/com/baidu/palo/analysis/LiteralExpr.java
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ public boolean equals(Object obj) {
if (!(obj instanceof LiteralExpr)) {
return false;
}

//TODO chenhao16, call super.equals()
if ((obj instanceof StringLiteral && !(this instanceof StringLiteral))
|| (this instanceof StringLiteral && !(obj instanceof StringLiteral))
|| (obj instanceof DecimalLiteral && !(this instanceof DecimalLiteral))
|| (this instanceof DecimalLiteral && !(obj instanceof DecimalLiteral))) {
return false;
}
return this.compareLiteral(((LiteralExpr) obj)) == 0;
}
}
Expand Down
8 changes: 6 additions & 2 deletions fe/src/com/baidu/palo/catalog/Catalog.java
Original file line number Diff line number Diff line change
Expand Up @@ -3346,7 +3346,9 @@ public static void getDdlStmt(Table table, List<String> createTableStmt, List<St
if (idx++ != 0) {
sb.append(",\n");
}
sb.append(" ").append(column.toSql());
// There MUST BE 2 space in front of each column description line
// sqlalchemy requires this to parse SHOW CREATE TAEBL stmt.
sb.append(" ").append(column.toSql());
}
sb.append("\n) ENGINE=");
sb.append(table.getType().name());
Expand All @@ -3370,7 +3372,9 @@ public static void getDdlStmt(Table table, List<String> createTableStmt, List<St
if (separatePartition) {
partitionId = Lists.newArrayList();
}
sb.append("\n").append(partitionInfo.toSql(olapTable, partitionId));
if (partitionInfo.getType() == PartitionType.RANGE) {
sb.append("\n").append(partitionInfo.toSql(olapTable, partitionId));
}

// distribution
DistributionInfo distributionInfo = olapTable.getDefaultDistributionInfo();
Expand Down
4 changes: 1 addition & 3 deletions fe/src/com/baidu/palo/catalog/Column.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,7 @@ public String toSql() {
if (aggregationType != null && !isAggregationTypeImplicit) {
sb.append(aggregationType.name()).append(" ");
}
if (isAllowNull) {
sb.append("NULL ");
} else {
if (!isAllowNull) {
sb.append("NOT NULL ");
}
if (defaultValue != null) {
Expand Down
1 change: 1 addition & 0 deletions fe/src/com/baidu/palo/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ private void sendFields(List<String> colNames, List<Expr> exprs) throws IOExcept
}

public void sendShowResult(ShowResultSet resultSet) throws IOException {
context.updateReturnRows(resultSet.getResultRows().size());
// Send meta data.
sendMetaData(resultSet.getMetaData());

Expand Down
21 changes: 16 additions & 5 deletions gensrc/parser/sql_parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ terminal String KW_ADD, KW_AFTER, KW_AGGREGATE, KW_ALL, KW_ALTER, KW_AND, KW_ANT
KW_RANDOM, KW_RANGE, KW_READ, KW_RECOVER, KW_REGEXP, KW_RELEASE, KW_RENAME,
KW_REPEATABLE, KW_REPLACE, KW_RESOURCE, KW_RESTORE, KW_REVOKE,
KW_RIGHT, KW_ROLLBACK, KW_ROLLUP, KW_ROW, KW_ROWS,
KW_SELECT, KW_SEMI, KW_SERIALIZABLE, KW_SESSION, KW_SET, KW_SHOW,
KW_SCHEMAS, KW_SELECT, KW_SEMI, KW_SERIALIZABLE, KW_SESSION, KW_SET, KW_SHOW,
KW_SMALLINT, KW_SNAPSHOT, KW_SONAME, KW_SPLIT, KW_START, KW_STATUS, KW_STORAGE, KW_STRING,
KW_SUM, KW_SUPERUSER, KW_SYNC, KW_SYSTEM,
KW_TABLE, KW_TABLES, KW_TABLET, KW_TERMINATED, KW_THAN, KW_THEN, KW_TIMESTAMP, KW_TINYINT,
Expand Down Expand Up @@ -255,7 +255,7 @@ nonterminal SelectStmt select_stmt;

// No return.
nonterminal describe_command, opt_full, opt_inner, opt_outer, from_or_in, keys_or_index, opt_storage, opt_wild_where,
charset, equal, transaction_characteristics, isolation_level,
charset, opt_charset_name, equal, transaction_characteristics, isolation_level,
transaction_access_mode, isolation_types;

// String
Expand Down Expand Up @@ -1564,6 +1564,10 @@ show_param ::=
{:
RESULT = new ShowDbStmt(parser.wild, parser.where);
:}
| KW_SCHEMAS opt_wild_where
{:
RESULT = new ShowDbStmt(parser.wild, parser.where);
:}
/* Columns */
| opt_full KW_COLUMNS from_or_in table_name:table opt_db:db opt_wild_where
{:
Expand Down Expand Up @@ -1732,6 +1736,11 @@ old_or_new_charset_name_or_default ::=
:}
;

opt_charset_name ::=
/* empty */
| charset old_or_new_charset_name_or_default
;

opt_collate ::=
/* Empty */
{:
Expand Down Expand Up @@ -2523,7 +2532,7 @@ select_sublist ::=
;

select_list_item ::=
expr:expr select_alias:alias
expr:expr opt_collate:collate select_alias:alias
{:
RESULT = new SelectListItem(expr, alias);
:}
Expand Down Expand Up @@ -2843,6 +2852,10 @@ cast_expr ::=
{: RESULT = new CastExpr(Type.fromPrimitiveType((PrimitiveType) targetType), e, false); :}
| KW_CAST LPAREN expr:e KW_AS primitive_type:targetType LPAREN non_pred_expr:e1 RPAREN RPAREN
{: RESULT = new CastExpr(Type.fromPrimitiveType((PrimitiveType) targetType), e, false); :}
| KW_CAST LPAREN expr:e KW_AS KW_CHAR opt_charset_name RPAREN
{: RESULT = new CastExpr(Type.fromPrimitiveType(PrimitiveType.VARCHAR), e, false); :}
| KW_CAST LPAREN expr:e KW_AS KW_CHAR LPAREN non_pred_expr:e1 RPAREN opt_charset_name RPAREN
{: RESULT = new CastExpr(Type.fromPrimitiveType(PrimitiveType.VARCHAR), e, false); :}
;

case_expr ::=
Expand Down Expand Up @@ -3271,8 +3284,6 @@ column_ref ::=
primitive_type ::=
KW_TINYINT
{: RESULT = PrimitiveType.TINYINT; :}
| KW_CHAR
{: RESULT = PrimitiveType.VARCHAR; :}
| KW_SMALLINT
{: RESULT = PrimitiveType.SMALLINT; :}
| KW_INT
Expand Down
1 change: 1 addition & 0 deletions gensrc/parser/sql_scanner.flex
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ import com.baidu.palo.common.util.SqlUtils;
keywordMap.put("rollup", new Integer(SqlParserSymbols.KW_ROLLUP));
keywordMap.put("row", new Integer(SqlParserSymbols.KW_ROW));
keywordMap.put("rows", new Integer(SqlParserSymbols.KW_ROWS));
keywordMap.put("schemas", new Integer(SqlParserSymbols.KW_SCHEMAS));
keywordMap.put("select", new Integer(SqlParserSymbols.KW_SELECT));
keywordMap.put("semi", new Integer(SqlParserSymbols.KW_SEMI));
keywordMap.put("serializable", new Integer(SqlParserSymbols.KW_SERIALIZABLE));
Expand Down