You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "foxes (JIRA)" <ji...@apache.org> on 2018/04/28 09:34:00 UTC
[jira] [Comment Edited] (CALCITE-2283) aggregate over empty set ,
throw java.lang.NullPointerException
[ https://issues.apache.org/jira/browse/CALCITE-2283?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16456020#comment-16456020 ]
foxes edited comment on CALCITE-2283 at 4/28/18 9:33 AM:
---------------------------------------------------------
When run the following code, the code throw java.lang.NullPointerException.
{code:java}
public static void main(String[] args) throws Exception {
Class.forName("org.apache.calcite.jdbc.Driver");
Properties info = new Properties();
info.setProperty("lex", "JAVA");
CalciteConnection calciteConnection =
(CalciteConnection) DriverManager.getConnection("jdbc:calcite:", info);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
Statement statement = calciteConnection.createStatement();
ResultSet resultSet = statement.executeQuery(
" select count(e.empid)," +
" count(DISTINCT (e.empid)) "+
" from hr.emps as e " +
" where 1=2"
);
resultSet.next();// this throw java.lang.NullPointerException.
for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) {
System.out.print(resultSet.getMetaData().getColumnName(i + 1) + ":" + resultSet.getString(i + 1) + "\t");
}
resultSet.close();
statement.close();
calciteConnection.close();
}
{code}
was (Author: hu_f):
I can reproduce this problem with the following code.
{code:java}
public static void main(String[] args) throws Exception {
Class.forName("org.apache.calcite.jdbc.Driver");
Properties info = new Properties();
info.setProperty("lex", "JAVA");
CalciteConnection calciteConnection =
(CalciteConnection) DriverManager.getConnection("jdbc:calcite:", info);
SchemaPlus rootSchema = calciteConnection.getRootSchema();
rootSchema.add("hr", new ReflectiveSchema(new JdbcTest.HrSchema()));
Statement statement = calciteConnection.createStatement();
ResultSet resultSet = statement.executeQuery(
" select count(e.empid)," +
" count(DISTINCT (e.empid)) "+
" from hr.emps as e " +
" where 1=2"
);
resultSet.next();// this throw java.lang.NullPointerException.
for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) {
System.out.print(resultSet.getMetaData().getColumnName(i + 1) + ":" + resultSet.getString(i + 1) + "\t");
}
resultSet.close();
statement.close();
calciteConnection.close();
}
{code}
> aggregate over empty set , throw java.lang.NullPointerException
> ---------------------------------------------------------------
>
> Key: CALCITE-2283
> URL: https://issues.apache.org/jira/browse/CALCITE-2283
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.16.0
> Reporter: foxes
> Assignee: Julian Hyde
> Priority: Major
>
> {code:java}
> //代码
> String sql =
> "select " +
> " count(distinct(bill_id)) as FULLY_REPAY_BILLS2_LST6 ," +
> " count(last_month) . as FULLY_REPAY_MONTHS_LST6 " +
> "from " +
> " cardBill " +
> "WHERE " +
> " 1=2 ";
> ResultSet result = st.executeQuery(sql.toUpperCase());
> result.next();// this throw NullPointerException
> {code}
> {code:java}
>
> Exception in thread "main" java.lang.NullPointerException
> at Baz$4$1.current(Unknown Source)
> at org.apache.calcite.linq4j.Linq4j$EnumeratorIterator.next(Linq4j.java:688)
> at org.apache.calcite.avatica.util.IteratorCursor.next(IteratorCursor.java:46)
> at org.apache.calcite.avatica.AvaticaResultSet.next(AvaticaResultSet.java:207)
> at com.terry.netease.calcite.test.test.TestMemoryQuery.main(TestMemoryQuery.java:84)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147){code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)