[
https://issues.apache.org/jira/browse/CALCITE-2535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16611539#comment-16611539
]
Hongze Zhang edited comment on CALCITE-2535 at 9/12/18 3:59 AM:
----------------------------------------------------------------
[~julianhyde] Thank you very much for your patient explanation.
For this case
{quote}select x / y from (table identity(cursor values (1, 0)) as t (x, y)
{quote}
Could you please explain why a simpler case like
{code:sql}
select x / y from (values (1, 0) as t (x, y)
{code}
is not enough? See generated code:
{code:java}
org.apache.calcite.DataContext root;
public org.apache.calcite.linq4j.Enumerable bind(final
org.apache.calcite.DataContext root0) {
root = root0;
final org.apache.calcite.linq4j.Enumerable _inputEnumerable =
org.apache.calcite.linq4j.Linq4j.asEnumerable(new Object[] {
new Object[] {
1,
0}});
return new org.apache.calcite.linq4j.AbstractEnumerable(){
public org.apache.calcite.linq4j.Enumerator enumerator() {
return new org.apache.calcite.linq4j.Enumerator(){
public final org.apache.calcite.linq4j.Enumerator inputEnumerator =
_inputEnumerable.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
return org.apache.calcite.runtime.SqlFunctions.toInt(current[0])
/ org.apache.calcite.runtime.SqlFunctions.toInt(current[1]);
}
};
}
};
}
public Class getElementType() {
return int.class;
}
{code}
Constant will not be performed because the IndexExpression "current[x]" is not
a constant.
And could please tell a bit more about the table function *identity.* e.g. what
kind of table it constructs, what does the *cursor* mean, or where can I found
a spec about this, thank you.
was (Author: zhztheplayer):
[~julianhyde] Thank you very much for the explanation.
For this case
{quote}select x / y from (table identity(cursor values (1, 0)) as t (x, y)
{quote}
Could you please explain why a simpler case like
{code:sql}
select x / y from (values (1, 0) as t (x, y)
{code}
is not enough? See generated code:
{code:java}
org.apache.calcite.DataContext root;
public org.apache.calcite.linq4j.Enumerable bind(final
org.apache.calcite.DataContext root0) {
root = root0;
final org.apache.calcite.linq4j.Enumerable _inputEnumerable =
org.apache.calcite.linq4j.Linq4j.asEnumerable(new Object[] {
new Object[] {
1,
0}});
return new org.apache.calcite.linq4j.AbstractEnumerable(){
public org.apache.calcite.linq4j.Enumerator enumerator() {
return new org.apache.calcite.linq4j.Enumerator(){
public final org.apache.calcite.linq4j.Enumerator inputEnumerator =
_inputEnumerable.enumerator();
public void reset() {
inputEnumerator.reset();
}
public boolean moveNext() {
return inputEnumerator.moveNext();
}
public void close() {
inputEnumerator.close();
}
public Object current() {
final Object[] current = (Object[]) inputEnumerator.current();
return org.apache.calcite.runtime.SqlFunctions.toInt(current[0])
/ org.apache.calcite.runtime.SqlFunctions.toInt(current[1]);
}
};
}
};
}
public Class getElementType() {
return int.class;
}
{code}
Constant will not be performed because the IndexExpression "current[x]" is not
a constant.
And could please tell a bit more about the table function *identity.* e.g. what
kind of table it constructs, what does the *cursor* mean, or where can I found
a spec about this, thank you.
> Runtime failure check not working in SqlTesterImpl.java
> -------------------------------------------------------
>
> Key: CALCITE-2535
> URL: https://issues.apache.org/jira/browse/CALCITE-2535
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Hongze Zhang
> Assignee: Julian Hyde
> Priority: Major
>
> Problem at SqlTesterImpl#checkFails:
> When argument "runtime" is specified as true, error assertion and error
> message matching will not be performed.
> This issue could result in wrong test result in SqlOperatorBaseTest.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)