Skip to content

Commit

Permalink
Update RexBuilder.clean method to handle MAP and ANY type
Browse files Browse the repository at this point in the history
  • Loading branch information
murermader committed Oct 11, 2024
1 parent 233fc2a commit cfb33ef
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions core/src/main/java/org/polypheny/db/rex/RexBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
import org.polypheny.db.type.entity.category.PolyNumber;
import org.polypheny.db.type.entity.numerical.PolyBigDecimal;
import org.polypheny.db.type.entity.numerical.PolyDouble;
import org.polypheny.db.type.entity.relational.PolyMap;
import org.polypheny.db.type.entity.temporal.PolyDate;
import org.polypheny.db.type.entity.temporal.PolyTime;
import org.polypheny.db.type.entity.temporal.PolyTimestamp;
Expand Down Expand Up @@ -1221,11 +1222,17 @@ private RexLiteral makeArray( List<PolyValue> value, AlgDataType type, boolean a
/**
* Converts the type of value to comply with {@link RexLiteral#valueMatchesType}.
*/
private static PolyValue clean( Object o, AlgDataType type ) {
private PolyValue clean( Object o, AlgDataType type ) {
if ( o == null ) {
return null;
}
switch ( type.getPolyType() ) {

PolyType polyType = type.getPolyType();
if ( polyType == PolyType.ANY ) {
polyType = guessType( o ).getPolyType();
}

switch ( polyType ) {
case TINYINT:
case SMALLINT:
case INTEGER:
Expand Down Expand Up @@ -1344,6 +1351,13 @@ private static PolyValue clean( Object o, AlgDataType type ) {
return PolyBinary.of( new ByteString( bytes ) );
}
break;
case MAP:
if ( o instanceof PolyMap map ) {
return map;
} else if ( o instanceof Map map ) {
return PolyMap.of( map );
}
break;
default:
if ( o instanceof PolyValue ) {
return (PolyValue) o;
Expand Down Expand Up @@ -1400,6 +1414,7 @@ public RexLiteral makeArray( AlgDataType type, List<PolyValue> operands ) {


public RexLiteral makeMap( AlgDataType type, Map<RexNode, RexNode> operands ) {
//PolyMap.of(operands)
return new RexLiteral( null, type, type.getPolyType() ); // todo fix this
}

Expand Down

0 comments on commit cfb33ef

Please sign in to comment.