6. What’s wrong with AQL?
● AQL is SQL-like but not SQL
● AQL implements only small subset of SQL
○ No complex where expressions, order by, join, group by, having , functions
● There is no JDBC driver for AQL dialect
6
10. Project home
● The driver is available on github.
● Please refer to README.md for more information
10
11. Quick start
Add driver to your classpath
Copy aerospike-jdbc-driver-all.jar to your lib folder
<dependency>
<groupId>com.nosqldriver</groupId>
<artifactId>aerospike-jdbc-driver</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
compile group: 'com.nosqldriver', name: 'aerospike-jdbc-driver', version: '1.0-SNAPSHOT'
11
The driver is still not available in public
repository. If you want to use it via maven or
gradle deploy it to your private repository.
14. SQL compliance: statements
● DDL
○ CREATE STRING INDEX
○ CREATE NUMERIC INDEX
○ DROP INDEX
○ USE
● DML
○ INSERT
○ SELECT
○ UPDATE
○ DELETE
○ UNION and UNION ALL
List index is not supported right now
14
15. SQL compliance: namespace
● Namespace is treated as JDBC catalog
● Connection can include namespace. In this case namespace could be omitted
in SQL queries
● If connection does not include namespace it must be written in query
● USE statement can be used to switch to other namespace
Connection string SQL query
jdbc:aerospike:localhost/ test select * from people
jdbc:aerospike:localhost select * from test.people
15
16. SQL compliance: SELECT
● select * from TABLE
● select name1, name2 from TABLE
● LIMIT, OFFSET
● WHERE
● Calculations
○ select year_of_birth-1900 from people
○ select 1+2
16
17. SQL compliance: WHERE
● Comparison operators: =, !=, <>, <, >, <=, >=, between, in, like
● Transparent access to indexed and not indexed field
● Special keyword PK is used to refer to the primary key
● Any combination of and/or keywords and parentheses are supported
● In complex queries that include both indexed and non indexed
fields the first indexed field will use filter API, all others will use
predicate API
● PK supports = and != only
17
18. SQL compliance: INSERT, UPDATE, DELETE
insert into people
(PK, first_name, last_name, year_of_birth, kids_count) values
(1, 'John', 'Lennon', 1940, 2)
update people set band='Beatles'
delete from people where PK=1
delete from people where year_of_birth=1940
18
20. Data manipulation functions
● String functions
○ len
○ ascii
○ char
○ charindex
○ lower
○ upper
○ str
○ substr
○ space
○ concat
○ reverse
● Date/Time functions
○ now
○ year
○ month
○ dayofmonth
○ hour
○ minute
○ second
○ millisecond
○ date
○ epoch
Please refer to README.md for more information
● Implemented using javascript
● Names are case sensitive
● Functions can be called using
lower and upper case names
only
○ LEN & len are OK
○ Len will not work
20
21. Group by
select year_of_birth, count(*) from people
group by year_of_birth
having count(*) > 0
Group by is implemented in lua script
21
22. Having
select year_of_birth, count(*) from people group by
year_of_birth having count(*) > 0
select year_of_birth, count(*) as n from people group by
year_of_birth having n = 4 - 2
22
23. Join
select first_name, g.name as guitar, k.name as keyboards
from people as p
join guitars as g on p.id=g.person_id
join keyboards as k on p.id=k.person_id
Elements of joined table are requested one-by-one.
23
24. Nested select statements
select first_name, year_of_birth from (
select year_of_birth, first_name from (
select first_name, last_name, year_of_birth from people
)
)
24
25. Schema
Schema is discovered from data
● Schema is runtime information only. We do not store it
anywhere like Spring Data for Aerospike
25
26. Data types
● String (varchar)
● Number
● Blob (mapped to byte array)
● Clob & NClob (mapped to string)
● SQL Date, Time, Timestamp (stored as serializable java objects)
● Array (mapped to Aerospike list). Supports all primitive types
Geo location and map are not supported right now
26
27. API
● Statement
● Prepared statement
Prepared statement can be used with select and
insert only and not with update and delete right
now.
select first_name, last_name, kids from people where PK=?
insert into people
(PK, first_name, last_name, year_of_birth, kids_count)
values
(?, ?, ?, ?, ?)
27
28. Nearest future plans
● Respect fetch size > 1.
○ This will improve schema discovery
○ This should significantly improve performance of join
● Deploy artifact to public maven repository
● Add list index
● Add list operations: append, prepend, remove, filter
● Implement prepared statement for update and delete
● Improve using predicates and filters in where clause
● Validate integration with various tools (Pentaho, Tableau, Equalum etc)
● Write documentation
● Support SQL scripts
28
29. Further future plans
● Persistent data schema
● Comprehensive set of functions
● Configuration parameters
● Out-of-heap cache
● Licensing
● UDF
● Extendability
29
31. You are welcome to...
Try to use driver
Check out the source code
Report bugs
Comment on the code
Pull requests are very welcome
Suggest improvements,
features, ideas based on
needs of real users
31