Discussion:
[h2] NullPointerException on nesting a query that works on its own (H2 1.4.197)
Jayanta Majumder
2018-11-27 11:24:32 UTC
Permalink
Hi,
Firstly, thanks for the great tool that H2 is. I would like to report
what looks like a bug in H2.
The following query works but when compose it within a nested expression
(e.g. with <viewname> as (...) <some additional query>, shown highlighted
in yellow below), I get a NullPointer expression. Will it be possible to
take a look. The query relies on two function aliases defined in the
attached script.The attached script also has the insert statements required
to reproduce the issue. [*Warning! *the script has "drop all objects" at
the beginning to clean up the database at the beginning]

select "companyId","name","age"
from flatten('name,age,companyId', $$select xmlreadtable(s.payroll,
'//Employee[age>30]', 'name', './name', 'age', './age' ), s.id
from company s
$$) ;
companyId
<http://localhost:8085/query.do?jsessionid=1f2e2f79260a7aa01184bf3792df6492#>
name
<http://localhost:8085/query.do?jsessionid=1f2e2f79260a7aa01184bf3792df6492#>
age
<http://localhost:8085/query.do?jsessionid=1f2e2f79260a7aa01184bf3792df6492#>
1 Lisa 35
1 Tom 40
2 Rupert 37
2 Anna 35
2 Darren 40(5 rows, 19 ms)


with xmltable as (
select "companyId","name","age"
from flatten('name,age,companyId', $$select xmlreadtable(s.payroll,
'//Employee[age>30]', 'name', './name', 'age', './age' ), s.id
from company s
$$))
select * from xmltable;
View "(
SELECT
""companyId"",
""name"",
""age""
FROM PUBLIC.FLATTEN('name,age,companyId', STRINGDECODE('select
xmlreadtable(s.payroll, ''//Employee[age>30]'', ''name'', ''./name'',
''age'', ''./age'' ), s.id \r\n from company s\r\n '))
/* function */
)" is invalid: "General error: ""java.lang.NullPointerException""; SQL
statement:
select xmlreadtable(s.payroll, '//Employee[age>30]', 'name', './name',
'age', './age' ), s.id
from company s
[50000-197]"; SQL statement:
with xmltable as (
select "companyId","name","age"
from flatten('name,age,companyId', $$select xmlreadtable(s.payroll,
'//Employee[age>30]', 'name', './name', 'age', './age' ), s.id
from company s
$$))
select * from xmltable [90109-197]
<http://localhost:8085/query.do?jsessionid=1f2e2f79260a7aa01184bf3792df6492#>
90109/90109 (Help)
<http://h2database.com/javadoc/org/h2/api/ErrorCode.html#c90109>
--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h2-database+***@googlegroups.com.
To post to this group, send email to h2-***@googlegroups.com.
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.
Loading...