Project

Profile

Help

Bug #4330

NullPointerException with XQuery using tumbling window in right hand side of let expression

Added by Martin Honnen 6 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
XQuery conformance
Sprint/Milestone:
-
Start date:
2019-10-02
Due date:
% Done:

0%

Legacy ID:
Applies to branch:
9.9, trunk
Fix Committed on Branch:
9.9, trunk
Fixed in Maintenance Release:

Description

Running the XQuery 3.1 code

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'xml';
declare option output:indent 'yes';

declare variable $chunk-size as xs:integer external := 500;


let $results := 
    for tumbling window $chunk in /*/*
    start at $sp when $sp mod $chunk-size = 1
    return
        document {
            element { node-name(head($chunk)/..) } {
                $chunk
            }
        }
return $results instance of document-node()+

with Saxon-HE 9.9.1.5J from the command line generates a NullPointerException:

Saxon-HE 9.9.1.5J from Saxonica
Java version 1.8.0_221
Analyzing query from .\test-xquery-split-result-2.xq
java.lang.NullPointerException
        at net.sf.saxon.expr.flwor.WindowClause.copy(WindowClause.java:198)
        at net.sf.saxon.expr.flwor.FLWORExpression.copy(FLWORExpression.java:392)
        at net.sf.saxon.expr.LetExpression.inlineReferences(LetExpression.java:399)
        at net.sf.saxon.expr.LetExpression.optimize(LetExpression.java:331)
        at net.sf.saxon.expr.flwor.FLWORExpression.rewriteForOrLet(FLWORExpression.java:757)
        at net.sf.saxon.expr.flwor.FLWORExpression.optimize(FLWORExpression.java:470)
        at net.sf.saxon.query.XQueryExpression.<init>(XQueryExpression.java:89)
        at net.sf.saxon.Configuration.makeXQueryExpression(Configuration.java:3747)
        at net.sf.saxon.query.XQueryParser.makeXQueryExpression(XQueryParser.java:193)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:597)
        at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:658)
        at net.sf.saxon.s9api.XQueryCompiler.compile(XQueryCompiler.java:579)
        at net.sf.saxon.Query.compileQuery(Query.java:804)
        at net.sf.saxon.Query.doQuery(Query.java:321)
        at net.sf.saxon.Query.main(Query.java:101)
Fatal error during query: java.lang.NullPointerException:  (no message)

Input sample is attached.

This issue is probably related to https://saxonica.plan.io/issues/4329 but as the symptons are quite different (spurios warning versus exception) I have filed them separately.

input-sample-2000-records.xml (182 KB) Martin Honnen, 2019-10-02 14:14 input-sample-2000-records.xml

History

#1 Updated by Michael Kay 6 months ago

  • Status changed from New to In Progress

Reproduced as QT3 test case TumblingWindowExpr560.

Looks pretty simple: the endCondition for a window clause can be null, and expression.copy() is not checking for this.

#2 Updated by Michael Kay 6 months ago

  • Status changed from In Progress to Resolved
  • Assignee set to Michael Kay
  • Applies to branch trunk added
  • Fix Committed on Branch 9.9, trunk added

#3 Updated by O'Neil Delpratt 4 months ago

  • Status changed from Resolved to Closed
  • Fixed in Maintenance Release 9.9.1.6 added

Patch committed to the Saxon 9.9.1.6 maintenance release.

Please register to edit this issue

Also available in: Atom PDF