Skip to content

Commit

Permalink
adjusted cast of number values
Browse files Browse the repository at this point in the history
  • Loading branch information
datomo committed Aug 28, 2024
1 parent 7e78573 commit 7e4e02c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,8 @@ public boolean isNumber() {
public PolyNumber asNumber() {
if ( isNumber() ) {
return (PolyNumber) this;
}else if( isString() ){
return PolyFloat.convert( this.asString() );
}
throw cannotParse( this, PolyNumber.class );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.math.BigDecimal;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.sql.Statement;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -774,7 +775,7 @@ public void testQ1() throws SQLException {
SUM(l_extendedprice) AS sum_base_price,
SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price,
SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,
AVG(l_quantity) AS avg_qty,
AVG(l_quantity) AS avg_Fqty,
AVG(l_extendedprice) AS avg_price,
AVG(l_discount) AS avg_disc,
COUNT(*) AS count_order
Expand Down Expand Up @@ -1497,6 +1498,33 @@ public void testQ14() throws SQLException {
}
}

@Test
public void testCast() throws SQLException {
try ( JdbcConnection polyphenyDbConnection = new JdbcConnection( true ) ) {
Connection connection = polyphenyDbConnection.getConnection();
try ( Statement statement = connection.createStatement() ) {
initTables( statement );

try {
String query = """
SELECT l_extendedprice
FROM
lineitem
WHERE
l_extendedprice >= cast(? as Integer)""";

PreparedStatement prepare = connection.prepareStatement( query );
prepare.setString( 1, "3" );
prepare.execute();
connection.commit();
} finally {
connection.rollback();
dropTables( statement );
}
}
}
}


@Test
public void testQ15() throws SQLException {
Expand Down

0 comments on commit 7e4e02c

Please sign in to comment.