+ All Categories
Home > Documents > Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0...

Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0...

Date post: 03-Jul-2020
Category:
Upload: others
View: 14 times
Download: 1 times
Share this document with a friend
188
Ghislain Fourny Big Data Fall 2018 12. Querying pinkyone / 123RF Stock Photo
Transcript
Page 1: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

Ghislain Fourny

Big Data Fall 201812. Querying

pinkyone / 123RF Stock Photo

Page 2: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

2

Declarative Languages

What vs. How

Page 3: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

3

Functional Languages

Expression

for if thenelse where

order by

whileany

every

let return

exit with

=

+

Page 4: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

4

Ever played Lego?

Page 5: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

5

Ever played Lego?

if( )

then

else

Page 6: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

6

Ever played Lego?

if( )

then

else

my:func( )

Page 7: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

7

Ever played Lego?

if( )

then

else

my:func( )

Page 8: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

8

Ever played Lego?

if( )

then

else

my:func( )2

Page 9: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

9

Ever played Lego?

if( )

then

else

for $x in

let $y :=

return

my:func( )2

Page 10: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

10

Ever played Lego?

if( )

then

else

for $x in

let $y :=

return

my:func( )2

Page 11: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

11

Ever played Lego?

if( )

then

else

for $x in

let $y :=

return

my:func( )2

Page 12: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

12

Language ecosystemXML JSON

Navigation XPath JSONPathJSONSelect

Page 13: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

13

Language ecosystemXML JSON

Navigation XPath JSONPathJSONSelect

Transform XSLT JSONT

Page 14: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

14

Language ecosystemXML JSON

Navigation XPath JSONPathJSONSelect

Transform XSLT JSONTQuery XQuery 1.0/3.0 XQuery 3.1,

JSON Query, JSONiq

Page 15: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

15

Language ecosystemXML JSON

Navigation XPath JSONPathJSONSelect

Transform XSLT JSONTQuery XQuery 1.0/3.0 XQuery 3.1,

JSON Query, JSONiq

Update, Scripting

XQuery Update Facility & Scripting

JSONiq

Page 16: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

16

Try it out!

Page 17: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

17

XML Navigation (XPath, XQuery)

Page 18: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

18

Document example<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")

Page 19: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

19

Document example<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

Remember:This is a tree!

doc("myfile.xml")

Page 20: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

20

The slash operator<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")/countries

Page 21: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

21

The slash operator<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")/countries/country

Page 22: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

22

The slash operator<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")/countries/country/name

Page 23: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

23

Descendant axis<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/name

Page 24: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

24

Descendant axis<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//name

Page 25: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

25

The slash operator<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country

Page 26: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

26

Attribute axis<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/@code

Page 27: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

27

Explicit atomization<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/data(@code)

Page 28: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

28

Atomization<name>Switzerland</name>0<name>France</name>0<name>Germany</name>0<name>Italy</name>0<name>Austria</name>00

Switzerland,France,Germany,Italy,Austria,,,

data(…)

Page 29: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

29

Explicit atomization<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/data(@code)

Page 30: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

30

Filter expressions<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/@code[data(.) = "CH"]

Page 31: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

31

Parent abbreviation<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country/@code[data(.) = "CH"]/..

Page 32: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

32

Alternate possibility<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country[@code/data(.) = "CH"]

Page 33: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

33

Explicit element atomization<?xml&version="1.0"&encoding="UTF98"?>&<countries>&&&<country&code="CH">&&&&&<name>Switzerland</name>&&&</country>&&&<country&code="F">&&&&&<name>France</name>&&&</country>&&&<country&code="D">&&&&&<name>Germany</name>&&&</country>&&&<country&code="I">&&&&&<name>Italy</name>&&&</country>&&&<country&code="A">&&&&&<name>Austria</name>&&&</country>&</countries>&&

doc("myfile.xml")//country[@code/data(.) = "CH"]/name/data(.)

Page 34: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

34

With collections of trees... <?xml version="1.0" encoding="UTF-8"?> <country code="CH"> <name>Switzerland</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="F"> <name>France</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="D"> <name>Germany</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="I"> <name>Italy</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="A"> <name>Austria</name> </country>

collection("countries.xml")

Page 35: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

35

With collections of trees... <?xml version="1.0" encoding="UTF-8"?> <country code="CH"> <name>Switzerland</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="F"> <name>France</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="D"> <name>Germany</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="I"> <name>Italy</name> </country> <?xml version="1.0" encoding="UTF-8"?> <country code="A"> <name>Austria</name> </country>

collection("countries.xml")/country/name

Page 36: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

36

JSON Navigation (JSONiq, Sparksoniq)

Page 37: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

37

With a JSON document

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}parse-json(file:read-text("myfile.json"))

Page 38: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

38

With a JSON document

parse-json(file:read-text("myfile.json")).countries

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}

Page 39: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

39

With a JSON document

parse-json(file:read-text("myfile.json")).countries[]

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}

Page 40: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

40

With a JSON document

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}parse-json(file:read-text("myfile.json")).countries[].name

Page 41: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

41

With a JSON document

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}parse-json(file:read-text("myfile.json")).countries[].code

Page 42: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

42

With a JSON document

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}parse-json(file:read-text("myfile.json")).countries[][$$.code = "CH"]

Page 43: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

43

With a JSON document

{"countries" :

[{

"name" : "Switzerland","code" : "CH"

},{

"name" : "France","code" : "F"

},{

"name" : "Germany","code" : "D"

},{

"name" : "Italy","code" : "I"

},{

"name" : "Austria","code" : "A"

}]

}parse-json(file:read-text("myfile.json")).countries[][$$.code = "CH"].name

Page 44: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

44

With a JSON collection {"name" : "Switzerland","code" : "CH"

}{

"name" : "France","code" : "F"

}{

"name" : "Germany","code" : "D"

}{

"name" : "Italy","code" : "I"

}{

"name" : "Austria","code" : "A"

}

collection("countries")[$$.code = "CH"].name

Page 45: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

45

With a JSON Lines file

{ "name" : "Switzerland", "code" : "CH" }{ "name" : "France", "code" : "F" }{ "name" : "Germany", "code" : "D" }{ "name" : "Italy", "code" : "I" }{ "name" : "Austria", "code" : "A" }

json-file("countries.json")[$$.code = "CH"].name

Page 46: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

46

Construction(XPath, XQuery)

Page 47: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

47

Construction: Strings

"foo"

Page 48: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

48

Construction: String Escaping (with JSONiq)

"This is a line\nand this is a new line"

"This is a \"quote\""

Page 49: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

49

Construction: String Escaping (with XQuery)

"This is a line&#x000a;and this is a new line"

"This is a &quot;quote&quot;"

Page 50: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

50

Construction: Numbers

42

3.141592653589793238462650283279

-6.022E23

Page 51: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

51

Construction: Booleans

true()

false()

true

false

XQuery JSONiq

Page 52: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

52

Construction: Other Simple Types

date("2013-05-01")

dateTime("2013-06-21T05:00:00Z")

long("1234567890123")

Page 53: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

53

Construction: JSON (JSONiq)

[{ "foo" : "bar" },{ "bar" : [ 1, 2, true, null ]

]

Page 54: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

54

Construction: XML (XQuery)

<foo attr="value">Text<bar/><!-- comment --><?target pi?>

</foo>

Page 55: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

55

Construction: sequences (JSONiq)

[ 2, 3 ], true, "foo", { "f" : 1 }

Page 56: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

56

Construction: sequences (XQuery)

1, true(), "foo", <bar/>

Page 57: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

57

Construction: sequences

1 to 100

Page 58: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

58

XQuery and JSONiq: Basic Operations

Page 59: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

59

Basic Operations: Arithmetics

addition 1 + 1

substraction 42 - 10

multiplication 6 * 7

division 42.3 div 7.2

integer division 42 idiv 9

module 42 mod 9

Page 60: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

60

Basic Operations: Atomization (XML only)

<a>42</a> + 1

Page 61: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

61

Basic Operations: Atomization (XML only)

<a>42</a> + 1

42 + 1

Page 62: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

62

Basic Operations: Atomization (XML only)

<a>42</a> + 1

42 + 1

43

Page 63: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

63

Basic Operations: Empty sequence

() + 1

Page 64: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

64

Basic Operations: Empty sequence

()

() + 1

Page 65: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

65

Basic Operations: types

"foo" + 2

Page 66: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

66

Basic Operations: types

"foo" + 2ERROR

Page 67: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

67

Basic Operations: cardinality

(3, 4) + 2

Page 68: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

68

Basic Operations: cardinality

(3, 4) + 2ERROR

Page 69: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

69

Basic Operations: Strings

concatenation "foo" || "bar"concat("foo", "bar")string-join(

("foo", "bar", "foobar"),"-"

)

sub-string substr("foobar", 4, 3)

length string-length("foobar")

Page 70: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

70

Basic Operations: Value Comparison

equality 1 + 1 eq 2

inequality 6 * 7 ne 21 * 2

greater than 234 gt 123234 ge 123

less than 42.3 lt 7.242.3 le 7.2

Page 71: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

71

Basic Operations:Value Comparison

1 eq 2"foo" ne "bar1 lt 22 gt 32 le 24 ge 3

Page 72: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

72

Basic Operations:Value Comparison

1 eq 2"foo" ne "bar1 lt 22 gt 32 le 24 ge 3

Page 73: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

73

Basic Operations:Value Comparison

() le 2

Page 74: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

74

Basic Operations:Value Comparison

() le 2

()

Page 75: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

75

Basic Operations:Value Comparison

"foo" le 2

Page 76: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

76

Basic Operations:Value Comparison

"foo" le 2ERROR

Page 77: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

77

Basic Operations:General Comparison

(1, 2, 3, 4, 5) = 1

Page 78: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

78

Basic Operations:General Comparison

(1, 2, 3, 4, 5) = 1

=

Page 79: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

79

Basic Operations:General Comparison

(1, 2, 3, 4, 5) < (2, 3, 4, 5, 6)

Page 80: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

80

Basic Operations:General Comparison

(1, 2, 3, 4, 5) < (2, 3, 4, 5, 6)

<

Page 81: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

81

Basic Operations:General Comparison

(1, 2, 3, 4, 5) >= (6, 7, 8, 9, 10)

Page 82: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

82

Basic Operations:General Comparison

(1, 2, 3, 4, 5) >= (6, 7, 8, 9, 10)

Page 83: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

83

Basic Operations:General Comparison

(1, 2, 3, 4, 5) >= ("foo", 7, 8, 9, 10)

Page 84: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

84

Basic Operations:General Comparison

(1, 2, 3, 4, 5) >= ("foo", 7, 8, 9, 10)ERROR

Page 85: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

85

Basic Operations:General Comparison

<?xml version="1.0" encoding="UTF-8"?> <countries> <country code="CH"> <name>Switzerland</name> </country> <country code="F"> <name>France</name> </country> <country code="D"> <name>Germany</name> </country> <country code="I"> <name>Italy</name> </country> <country code="A"> <name>Austria</name> </country> </countries>

doc("myfile.xml")//name = "Switzerland"

Page 86: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

86

Basic Operations:General Comparison

<?xml version="1.0" encoding="UTF-8"?> <countries> <country code="CH"> <name>Switzerland</name> </country> <country code="F"> <name>France</name> </country> <country code="D"> <name>Germany</name> </country> <country code="I"> <name>Italy</name> </country> <country code="A"> <name>Austria</name> </country> </countries>

doc("myfile.xml")//name = "Switzerland"

Page 87: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

87

Basic Operations:General Comparison

<?xml version="1.0" encoding="UTF-8"?> <countries> <country code="CH"> <name>Switzerland</name> </country> <country code="F"> <name>France</name> </country> <country code="D"> <name>Germany</name> </country> <country code="I"> <name>Italy</name> </country> <country code="A"> <name>Austria</name> </country> </countries>

doc("myfile.xml")//name = "Switzerland"

Page 88: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

88

Basic Operations:General Comparison

collection("countries").name = "Switzerland"

{"name" : "Switzerland","code" : "CH"

}{

"name" : "France","code" : "F"

}{

"name" : "Germany","code" : "D"

}{

"name" : "Italy","code" : "I"

}{

"name" : "Austria","code" : "A"

}

Page 89: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

89

Basic Operations: Logics

conjunction 1+1 eq 2 and 2+2 eq 4

disjunction 1+1 eq 2 or 2+2 eq 4

not not(100 mod 5 eq 0)

Page 90: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

90

Two-valued logics (JSONiq)

true and false

true or true

not false

not(true or not(false and true))

Page 91: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

91

Two-valued logics (XQuery)

true() and false()

true() or true()

not(false())

not(true() or not(false() and true()))

Page 92: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

92

Non-booleans

if("")...

Page 93: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

93

Non-booleans

if("foo")...

Page 94: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

94

Non-booleans

if(0)...

Page 95: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

95

Non-booleans

if(42)...

Page 96: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

96

Non-booleans

if(())...

Page 97: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

97

Non-booleans

if((<foo/>, <bar/>, 1, "foo"))...

Page 98: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

98

Non-booleans

if(({ "foo" : "bar" }, 1, "foo"))...

Page 99: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

99

Composability

Page 100: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

100

Rule of Thumb

Any Expressioncan be the operand of any other expression.

Page 101: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

101

Composability

(1 + ((<b><a>{2+2}</a></b>)/a)) to 50

Page 102: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

102

Composability

(1 + ((<b><a>{4}</a></b>)/a)) to 50

Page 103: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

103

Composability

(1 + ((<b><a>4</a></b>)/a)) to 50

Page 104: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

104

Composability

(1 + (<a>4</a>)) to 50

Page 105: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

105

Composability

(1 + 4) to 50

Page 106: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

106

Composability

5 to 50

Page 107: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

107

Composability

5, 6, 7, ..., 49, 50

Page 108: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

108

Composability

(1 + (({"b":[{"a": 2+2}]}).b[].a)) to 50

Page 109: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

109

PrecedencePrecedence (low first)CommaData Flow (FLWOR, if-then-else, switch...)LogicComparisonString concatenationRangeArithmeticPath expressionsFilter predicates, dynamic function callsLiterals, constructors and variablesFunction calls, named function references, inline functions

Page 110: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

110

PrecedencePrecedence (low first)CommaData Flow (FLWOR, if-then-else, switch...)LogicComparisonString concatenationRangeArithmeticPath expressionsFilter predicates, dynamic function callsLiterals, constructors and variablesFunction calls, named function references, inline functions

Use parentheses to override or when in doubt!

Page 111: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

111

XML Construction reloaded<foo attr="{string-length("foobar")}">{string-join(for $i in 1 to 10 return string($i),"-"

)}</foo>

Page 112: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

112

XML Construction reloaded<foo attr="{string-length("foobar")}">{string-join(for $i in 1 to 10 return string($i),"-"

)}</foo>

<foo attr="6">1-2-3-4-5-6-7-8-9-10</foo>

Page 113: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

113

JSON Construction reloaded{"attr" : string-length("foobar")"values" : [for $i in 1 to 10return string($i)

]}

Page 114: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

114

JSON Construction reloaded{"attr" : string-length("foobar")"values" : [for $i in 1 to 10return string($i)

]}

{"attr" : 6,"values" : [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

}

Page 115: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

115

Data Flow(XQuery, JSONiq)

Page 116: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

116

Conditional Expressions

if(count(doc("file.xml")//country) gt 1000)then "Large file!"else "Small file."

Page 117: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

117

Switch Expressions

switch($country/code)case "CH" return("gsw", "de", "fr", "it", "rm")

case "F" return "fr"case "D" return "de"case "I" return "it"default return "en"

Page 118: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

118

Try Catch Expressions

try {xs:integer($country/code)

} catch * {"A country code is not an integer!"

}

Page 119: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

119

FLWOR Expressions(XQuery, JSONiq)

Alexander Raths / 123RF Stock Photo

Page 120: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

120

Let clauses

let $x := 2return $x * $x

Page 121: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

121

For clauses

for $x in (1, 2, 4)return $x * $x

Page 122: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

122

Where clauses

for $x in 1 to 10where $x - 2 gt 5return $x * $x

Page 123: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

123

For clauses

for $x in 1 to 10return{"number": $x,"square": $x * $x

}

Page 124: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

124

Order by clauses

for $x in collection("countries")order by $x.populationreturn $x.name

Page 125: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

125

Group by clauses{

"continents" : [for $x in collection("countries")group by $continent := $x.continentreturn{

"code": $continent,"countries" : [

for $country in $xreturn $country.name

]}

]}

Page 126: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

126

Tuple stream semantics

for $x in 1 to 10

where $x - 2 gt 5

return $x * $x

Page 127: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

127

Tuple stream semantics

for $x in 1 to 10

where $x - 2 gt 5

return $x * $x

x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10

Page 128: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

128

Tuple stream semantics

for $x in 1 to 10

where $x - 2 gt 5

return $x * $x

x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10

x 8 x 9 x 10

Page 129: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

129

Tuple stream semantics

for $x in 1 to 10

where $x - 2 gt 5

return $x * $x

x 1 x 2 x 3 x 4 x 5 x 6 x 7 x 8 x 9 x 10

x 8 x 9 x 10

(64, 81, 100)

Page 130: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

130

Tuple stream semantics

for $x in 1 to 5

let $y := $x - 2

return $x * $y

Page 131: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

131

Tuple stream semantics

for $x in 1 to 5

let $y := $x - 2

return $x * $y

x 1 x 2 x 3 x 4 x 5

Page 132: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

132

Tuple stream semantics

for $x in 1 to 5

let $y := $x - 2

return $x * $y

x 1 x 2 x 3 x 4 x 5

x 1 x 2 x 3 x 4 x 5y -1 y 0 y 1 y 2 y 3

Page 133: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

133

Tuple stream semantics

for $x in 1 to 5

let $y := $x - 2

return $x * $y

x 1 x 2 x 3 x 4 x 5

x 1 x 2 x 3 x 4 x 5y -1 y 0 y 1 y 2 y 3

(-1, 0, 3, 8, 15)

Page 134: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

134

Tuple stream semanticsfor $x in 1 to 5

group by $y := $x mod 2

return {"foo" : $y,"bar" : count($x)

}

Page 135: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

135

Tuple stream semanticsfor $x in 1 to 5

group by $y := $x mod 2

return {"foo" : $y,"bar" : count($x)

}

x 1 x 2 x 3 x 4 x 5

Page 136: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

136

Tuple stream semanticsfor $x in 1 to 5

group by $y := $x mod 2

return {"foo" : $y,"bar" : count($x)

}

x 1 x 2 x 3 x 4 x 5

y 0 y 1

Page 137: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

137

Tuple stream semanticsfor $x in 1 to 5

group by $y := $x mod 2

return {"foo" : $y,"bar" : count($x)

}

x 1 x 2 x 3 x 4 x 5

y 0 x 2 4 y 1 x 1 3 5

Page 138: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

138

Tuple stream semanticsfor $x in 1 to 5

group by $y := $x mod 2

return {"foo" : $y,"bar" : count($x)

}

x 1 x 2 x 3 x 4 x 5

y 0 x 2 4 y 1 x 1 3 5

{ "foo" : 0, "bar" : 2 }, { "foo" : 1, "bar" : 3 }

Page 139: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

139

Types

Page 140: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

140

Types

§ Simple types: by name

integer

Page 141: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

141

Types

§ Simple types: by name

integer§ Complex types: by kind

object

Page 142: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

142

Cardinality (JSON/JSONiq)

integerboolean?array+object*

Page 143: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

143

Cardinality (XML/XQuery)

xs:integerxs:boolean?element(foo)+

document-node()*

Page 144: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

144

Type usage

let $x as integer := 2return $x + $x

Page 145: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

145

Type usage

let $x as object :={ "foo" : 1, "bar" : 2 }

return $x.foo + $x.bar

Page 146: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

146

Type usage

for $x as array in ([ 1 ],[ 2 ]

)return $x[] + $x[]

Page 147: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

147

Type usage (XQuery)

let $x as node() :=<foo>2</foo>

return $x + $x

Page 148: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

148

Type usage

for $x as array* in ([ 1 ],[ 2 ]

)return $x + $x treat as integer

Page 149: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

149

Type usage

for $x as array* in ([ 1 ],[ 2 ]

)return $x + $x cast as double

Page 150: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

150

Type usage

for $x as array* in ([ 1 ],[ 2 ]

)return double($x + $x)

Page 151: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

151

Type usage

3.14 instance of integer

Page 152: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

152

Type usage

3.14 castable as double

Page 153: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

153

Type usage

declare function local:is-big-data($threshold as integer,$objects as object*

) as boolean{count($objects) gt $threshold

};

Page 154: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

154

Type usage

declare function local:is-big-data($threshold as integer,$objects as object*

) as boolean{count($objects) gt $threshold

};

local:is-big-data(1000, collection("countries"))

Page 155: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

155

Validationimport'schema'namespace'm!=!http://www.w3.org/1998/Math/MathML!!!at!"http://www.w3.org/Math/XMLSchema/mathml3/mathml3.xsd";!!validate!{!<m:math!xmlns:m="http://www.w3.org/1998/Math/MathML">!!!<m:apply>!!!!!<m:eq/>!!!!!<m:ci>!!!!!!!x!!!!!</m:ci>!!!!!<m:apply>!!!!!!!<m:root/>!!!!!!!<m:cn>!!!!!!!!!2!!!!!!!</m:cn>!!!!!</m:apply>!!!</m:apply>!!</m:math>!}!!

Page 156: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

156

Not covered

§ Advanced XPath (kind tests, axes, ...)§ Higher-order functions§ Count clause§ Window clause§ Node comparison§ Errors§ Typeswitch

Page 157: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

157

There’s more

Updates

XQuery Full-Text

Scripting

insert node <foo/> into $doc/bar

/books/book[@number="1"]/titlecontains text "improve" using stemming

while ($x gt 0) { $x := $x – 1; }

Page 158: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

158

Architecture of a query processing engine

Page 159: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

159

Parsing

QueryAbstract Syntax Tree

count(for $i in json-lines("file.json")return $i.field

)

"file.json"

json-lines() .field

$i

returnfor

FLWOR

count()

$i

Page 160: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

160

Translating

Abstract Syntax Tree

"file.json"

json-lines() .field

$i

returnfor

FLWOR

count()

$i

Expression Tree

StringLiteralExpression

JSONLinesFunctionCall ObjectLookupExpression

VariableExpression

ReturnClause

ForClause

FLWORExpression

CountFunctionCall

VariableExpression

StringLiteralExpression

Page 161: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

161

Optimization

Expression Tree

StringLiteralExpression

JSONLinesFunctionCall ObjectLookupExpression

VariableExpression

ReturnClause

ForClause

FLWORExpression

CountFunctionCall

VariableExpression

StringLiteralExpression

Page 162: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

162

Code Generation

Expression Tree

StringLiteralExpression

JSONFileFunctionCall ObjectLookupExpression

VariableExpression

ReturnClause

ForClause

FLWORExpression

CountFunctionCall

VariableExpression

StringLiteralExpressionStringIterator

JSONFileIterator

ObjectLookupExpression

VariableExpression

ReturnIterator

ForIterator

CountIterator

VariableName

StringLiteralExpression

Iterator Tree

Page 163: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

163

Execution

StringIterator

JSONFileIterator

ObjectLookupExpression

VariableExpression

ReturnIterator

ForIterator

CountIterator

VariableName

StringLiteralExpression

Sequence of items

Stream of tuples

Page 164: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

164

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Page 165: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

165

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Page 166: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

166

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

$i: { "field" : 1 }ReturnIterator

ForIterator

Stream of tuples

Page 167: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

167

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

$i: { "field" : 1 }$i: { "field" : 6 }

ReturnIterator

ForIterator

Stream of tuples

Page 168: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

168

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }

ReturnIterator

ForIterator

Stream of tuples

Page 169: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

169

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }

ReturnIterator

ForIterator

Stream of tuples

Page 170: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

170

Materialized execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Page 171: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

171

Materialized execution

ReturnIterator

ForIterator

Stream of tuples

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

16432

Page 172: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

172

Materialized execution

ReturnIterator

ForIterator

Stream of tuples

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

16432

Can take lots of memory!

Page 173: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

173

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Page 174: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

174

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples $i: { "field" : 1 }

Page 175: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

175

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

1

Page 176: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

176

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples $i: { "field" : 6 }

Page 177: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

177

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

6

Page 178: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

178

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples $i: { "field" : 4 }

Page 179: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

179

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

4

Page 180: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

180

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples $i: { "field" : 3 }

Page 181: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

181

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

3

Page 182: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

182

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples $i: { "field" : 2 }

Page 183: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

183

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

2

Page 184: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

184

Streamed execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

2

Can take lots of time!

Page 185: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

185

Parallel execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Page 186: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

186

Parallel execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

$i: { "field" : 1 }$i: { "field" : 6 }

$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

Page 187: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

187

Parallel execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

$i: { "field" : 1 }$i: { "field" : 6 }

$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

16

432

Page 188: Ghislain Fourny Big Data Fall 2018 - Systems Group …...Transform XSLT JSONT Query XQuery 1.0/3.0 XQuery 3.1, JSON Query, JSONiq Update, Scripting XQuery Update Facility & Scripting

188

Parallel execution

$i: { "field" : 1 }$i: { "field" : 6 }$i: { "field" : 4 }$i: { "field" : 3 }$i: { "field" : 2 }

ReturnIterator

ForIterator

Stream of tuples

Can take lots of machines!


Recommended