Adding Apache Derby support to GeoDB #19
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my first cut at adding Derby support to GeoDB. I'm creating an extension to Liquibase which required GeoDB for H2 support and I wanted to support Derby as well. Since Hatbox already supports Derby, I figured it wouldn't be too difficult to make GeoDB work with Derby as well.
Aside from aggregate functions (described below), I have successfully tested with Derby 10.8.2.2. Unit tests started failing older than that though the errors were strange enough that I didn't bother investigating.
GeoDB
I made little or no changes to the generic spatial methods in the
GeoDB
class. However, anything that performed SQL required some modifications to make it compatible with both H2 and Derby. I must say that I really like H2's more flexible SQL parsing because sometimes I just needed to add or remove a word to make the SQL work in both database. Derby doesn't have some of the niceties (e.g.IF EXISTS
clauses) found in H2 so I had to resort to either SQL or JDBC queries to work around this.Stored Procedures
Derby stored procedures don't support blob parameters so I used
LONG VARCHAR FOR BIT DATA
which has a maximum length of 32,700 bytes. This also means that blob geometry columns won't work in most if not all cases. Derby doesn't support stored function overloading so the alternate form of a couple functions (i.e.ST_MakeBox2D
andST_Relate
) are omitted.Aggregate Functions
Starting in version 10.10.1.1, Derby supports aggregate SQL functions. I added the Derby-specific interface to the
GeoAggregateFunction
class and mapped Derby's methods to the H2 methods.Unit Tests
First off, good job on having so many unit tests! This made my initial work so much easier. I had to do quite a bit of work to restructure the unit tests so that they executed in both H2 and Derby. Creating and deleting a Derby database is sloooow. I added a lot of unit tests to test the Derby stored function creation statements. I left some out because I had questions on their implementation. These two are the most notable:
ST_Envelope
-- It looks like this should return a Polygon and not a JTS Envelope.ST_MakeBox2D
-- I expected it to return WKB but I think it's returning EWKB.