[
https://issues.apache.org/jira/browse/CALCITE-3443?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16959366#comment-16959366
]
Wang Yanlin edited comment on CALCITE-3443 at 10/25/19 2:28 AM:
----------------------------------------------------------------
try this one in *RemotePreparedStatementParametersTest*
{code:java}
@Test public void testTimestampDiff() throws Exception {
// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithCalcite();
Connection connection = DriverManager.getConnection(server.getURL());
// when
PreparedStatement pS =
connection.prepareStatement(
"SELECT TIMESTAMPDIFF(DAY, CAST('2019-01-01' AS TIMESTAMP), CAST(?
AS TIMESTAMP)) > 0 as sent");
pS.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
// then
ResultSet resultSet = pS.executeQuery(); server.stop();
while (resultSet.next()) {
System.out.println(resultSet.getBoolean(1));
}
}
{code}
or
{code:java}
@Test public void testTimestampDiff() throws Exception {
// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithCalcite();
Connection connection = DriverManager.getConnection(server.getURL());
// when
PreparedStatement pS =
connection.prepareStatement(
"SELECT TIMESTAMPDIFF(DAY, CAST('2019-01-01' AS DATE), CAST(? AS
DATE)) > 0 as sent");
pS.setDate(1, new Date(System.currentTimeMillis()));
// then
ResultSet resultSet = pS.executeQuery(); server.stop();
while (resultSet.next()) {
System.out.println(resultSet.getBoolean(1));
}
}
{code}
was (Author: yanlin-lynn):
try this one in *RemotePreparedStatementParametersTest*
{code:java}
@Test public void testTimestampDiff() throws Exception {
// given
ChinookAvaticaServer server = new ChinookAvaticaServer();
server.startWithCalcite();
Connection connection = DriverManager.getConnection(server.getURL());
// when
PreparedStatement pS =
connection.prepareStatement(
"SELECT TIMESTAMPDIFF(DAY, CAST('2019-01-01' AS TIMESTAMP), CAST(?
AS TIMESTAMP)) > 0 as sent");
pS.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
// then
ResultSet resultSet = pS.executeQuery(); server.stop();
while (resultSet.next()) {
System.out.println(resultSet.getBoolean(1));
}
}
{code}
> Doesn't parse PreparedStatement successfully for there are placeholders in
> select area
> --------------------------------------------------------------------------------------
>
> Key: CALCITE-3443
> URL: https://issues.apache.org/jira/browse/CALCITE-3443
> Project: Calcite
> Issue Type: Bug
> Components: avatica
> Affects Versions: 1.21.0
> Environment: linux, mac
> Reporter: huaicui
> Priority: Major
>
> Calcite isn't able to parse the sql that there is a placeholder in select
> area, like this:
> {
> "sql":"SELECT TIMESTAMPDIFF(day, CAST('2019-01-01' AS DATE), CAST(? AS
> DATE))>0 as sent",
> "params":[
> {
> "className":"java.lang.String",
> "value":"2019-09-02"
> }
> ]
> }
> We have a scenario that need to set palceholder in select area, please help
> to fix that;
--
This message was sent by Atlassian Jira
(v8.3.4#803005)