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. Scope of this presentation
● This is an introduction to the driver. The driver is available on github.
● This is not a full manual. Please refer to README.md for more information
10
12. Quick start
Add driver to your classpath
Drop 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'
The driver is not available deployed to any
public repository. If you want to use it via
maven or gradle deploy it to your private
repository.
12
15. 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
15
16. 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
16
17. 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
17
18. 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
18
19. 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
19
21. 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
21
22. Group by
select year_of_birth, count(*) from people
group by year_of_birth
having count(*) > 0
Group by is implemented in lua script
22
23. 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
23
24. 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.
24
25. 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
)
)
25
26. Schema
Schema is discovered from data
● Right now only first line is used to discover the data schema
● Schema is runtime information only. We do not store it
anywhere like Spring Data for Aerospike
26
27. 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
27
28. API
● Statement
● Prepared statement
Prepared statement can be used with select and
insert only. Update and delete do not support
prepared statements 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
(?, ?, ?, ?, ?)
28
29. 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
29
30. Further future plans
● Persistent data schema
● Comprehensive set of functions
● Configuration parameters
● Out-of-heap cache
● Licensing
● UDF
● Extendability
30
32. Please...
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
32