RDF::Query

# RDF::Query - A SPARQL/RDQL implementation for RDF::Redland and RDF::Core

RDF::Query allows RDQL and SPARQL queries to be run against an RDF model, returning rows of matching results.

## Requirements

To install RDF::Query you'll need the following perl modules installed:

- RDF::Core or RDF::Redland
- Parse::RecDescent
- LWP::Simple
- DateTime::Format::W3CDTF
- JSON
- Error

## Installing RDF::Query

To install, run:

perl Makefile.PL
make
make test
make install

## Version History

### Version 1.035 (2006-06-04)

- Added DAWG tests and harness.
- Rewrote core logic in OPTIONAL handling code.
- Comparisons on literals now respect numeric datatypes.
- Fixed outdated calling conventions in casting functions.
- Added custom functions:
  - jena:sha1sum
  - jena:now
  - jena:langeq
  - jena:listMember
  - ldodds:Distance
- Added new model methods: equals, subject, predicate, object.
- Relocated external http-based test data to .Mac URLs.

### Version 1.034 (2006-05-01)

- Added JSON serialization for bindings and boolean queries.
- Initial support for compiling RDF queries to SQL queries using the Redland schema.
- Added to_string method to query results Stream class.
- Model objects now store the query parse tree for access to data needed in serialization.
- Unquoted number and boolean literals in SPARQL are now datatyped appropriately.
- Fixed crashing bug when RDF::Query::Model::Redland::as_string was called with an undefined value.
- Fixed bug parsing queries with predicate starting with 'a' (confused with { ?subj a ?type}).
- Fixed bug parsing queries whose triple pattern ended with the optional dot.

### Version 1.033 (2006-03-08)

- Updated test suite to work if one of the model classes is missing.
- Data-typed literals are now cast appropriately when used in a FILTER.
- Added support for xsd:dateTime datatypes using the DateTime module.
- Added support for LANG(), LANGMATCHES() and DATATYPE() built-in functions.
- Updated TODO list.
- Added more exception types to RDF::Query::Error.
- Added POD coverage.
- Fixed SPARQL parsing bug for logical operators <= and >=.

### Version 1.032 (2006-03-03)

- Replaced the Parse::RecDescent SPARQL parser with a much faster hand-written one.
- Updated SPARQL parsing rules to be better about URI and QName character sets.
- FILTER equality operator now '=', not '==' (to match SPARQL spec).
- Initial support for FILTER constraints as part of the triple pattern structure (Will allow for nested FILTERs).
- Implemented support for ordering query results by an expression.
- Fixed bug in expresion handling of unary minus.
- Fixed bug in Redland NAMED GRAPH parsing.
- Fixed bug in RDF::Core parsing code where blank nodes would be accidentally smushed.

### Version 1.031 (2006-02-08)

- Added support for NAMED graphs.

### Version 1.030 (2006-01-13)

- Added support for SELECT * in SPARQL queries.
- Added support for default namespaces in SPARQL queries.
- Added tests for querying RDF collections in SPARQL (1 ?x 3)
- Added tests for triple patterns of the form { ?a ?a ?b . }
- Added tests for default namespaces in SPARQL.
- Added tests for SELECT * SPARQL queries.
- Bugfix where one of two identical triple variables would be ignored ({ ?a ?a ?b }).

### Version 1.028 (2005-11-18)

- Added SPARQL functions: BOUND, isURI, isBLANK, isLITERAL.
- Updated SPARQL REGEX syntax.
- Updated SPARQL FILTER syntax.
- Added SPARQL RDF Collections syntactic forms.
- Fixed FILTER support in OPTIONAL queries.
- Added binding_value_by_name method to Query results stream class.
- Added isa_blank methods to RDF::Redland and RDF::Core model classes.
- Fixed RDF literal datatyping when using Redland versions >= 1.00_02.
- Updated SPARQL grammar to make 'WHERE' token optional.
- Added directives to SPARQL grammar.
- Updated SPARQL 'ORDER BY' syntax to use parenthesis.
- Fixed SPARQL FILTER logical-and support for more than two operands.
- Fixed SPARQL FILTER equality operator syntax to use '=' instead of '=='.
- Now requires Test::More 0.52 because of changes to is_deeply().

### Version 1.027 (2005-07-28)

- Updated to follow SPARQL Draft 2005.07.21:
  - ORDER BY arguments now use parenthesis.
  - SPARQL parser now supports ORDER BY operands: variable, expression, or function call.
- Added binding_value_by_name() method to query result streams.

### Version 1.026 (2005-06-05)

- Added new DBI model bridge (accesses Redland's mysql storage directly).
- Added built-in SPARQL functions and operators (not connected to grammar yet).
- Added bridge methods for accessing typed literal information.

### Version 1.024 (2005-06-02)

- Added missing SPARQL OFFSET grammar rules.
- Added XML Results support for graph and boolean queries (DESCRIBE, CONSTRUCT, ASK).
- Fixed major bugs in RDF::Core bridge:
  - - Bridge wasn't using passed model.
  - - Literal construction was broken.
  - - Blank node construction was broken when no identifier was specified.
- Stream::bindings_count now returns the right number even if there is no data.
- XML Result format now works with RDF::Core models.
- The Model bridge object is now passed to the Stream constructor.
- Internal code now uses the variables method.
- Removed redundant code from ORDER BY/LIMIT/OFFSET handling.
- Removed unused count method.
- Removed unused delegating AUTOLOAD.
- Removed unused parse_files method.
- Removed usused add_file method.
- Removed duplicate net test file.
- Added test file for local file-based SPARQL 'FROM' queries.
- Added test file for SPARQL Result Forms (LIMIT, ORDER BY, OFFSET, DISTINCT).
- Added test file for SPARQL Protocol for RDF (XML Results).
- Added new tests based on Devel::Cover results.
- Some test files now run against both Redland and RDF::Core:
  - - 00-simple.t
  - - 03-coverage.t
  - - 10-sparql_protocol.t
- All debugging is now centrally located in the _debug method.
- Moved Stream class to lib/RDF/Query/Stream.pm.
- Fixed tests that broke with previous fix to CONSTRUCT queries.
- Fixed tests that broke with previous change to ASK query results.

### Version 1.021 (2005-06-01)

- Added SPARQL UNION support.
- Broke OPTIONAL handling code off into a seperate method.
- Added new debugging code to trace errors in the twisty web of closures.

### Version 1.020 (2005-05-18)

- Added support for SPARQL OPTIONAL graph patterns.
- Calling bindings_count on a stream now returns 0 with no data.
- Added Stream methods:
  - is_bindings
  - binding_name
  - binding_values
  - binding_names
- Added as_xml method to Stream class for XML Binding Results format.

### Version 1.016 (2005-05-08)

- Added initial support for SPARQL ASK, DESCRIBE and CONSTRUCT queries.
  - Added new test files for new query types.
- Added methods to bridge classes for creating statements and blank nodes.
- Added as_string method to bridge classes for getting string versions of nodes.
- Broke out triple fixup code into fixup_triple_bridge_variables().
- Updated FILTER test to use new Geo::Distance API.

### Version 1.015 (2005-05-03)

- Fixes to the arguments passed to FILTERs.
- Filter tests now show example of two custom filters:
  - Transitive subClassOf testing.
  - Logical comparison operators (range testing lat/lon values).
- Added literal_value, uri_value, and blank_identifier methods to bridges.
- Redland bridge now calls sources/arcs/targets when only one field is missing.
- Fixes to stream code. Iterators are now destroyed in a timely manner.
  - Complex queries no longer max out mysql connections under Redland.
- Cleaned up node sorting code.
  - Removed dependency on Sort::Naturally.
  - Added new node sorting function ncmp().
- check_constraints now calls ncmp() for logical comparisons.
- Added get_value method to make bridge calls and return a scalar value.
- Fixed node creation in Redland bridge.
- Moved DISTINCT handling code to occur before LIMITing.
- Added variables method to retrieve bound variable names.
- Added binding_count and get_all methods to streams.
- get_statments bridge methods now return RDF::Query::Stream objects.

### Version 1.014 (2005-04-26)

- Made FILTERs work in SPARQL.
- Added initial SPARQL support for custom function constraints.
- SPARQL variables may now begin with the '$' sigil.
- Added direction support for ORDER BY (ascending/descending).
- Added 'next', 'current', and 'end' to Stream API.

### Version 1.012 (2005-04-24)

- Stream objects now handle being constructed with an undef coderef.
- Streams are now objects usinig the Redland QueryResult API.
- RDF namespace is now always available in queries.
- row() now uses a stream when calling execute().
- Added ORDER BY support to RDQL parser.
- SPARQL constraints now properly use the 'FILTER' keyword.
- SPARQL constraints can now use '&&' as an operator.
- SPARQL namespace declaration is now optional.
- Updated tests.

### Version 1.010 (2005-04-21)

- `execute` now returns an iterator
- Added core support for DISTINCT, LIMIT, OFFSET
- Added initial core support for ORDER BY (only works on one column right now)
- Broke out the query parser into it's own RDQL class
- Added initial support for a SPARQL parser
  - Added support for blank nodes
  - Added lots of syntactic sugar (with blank nodes, multiple predicates and objects)
  - Added SPARQL support for DISTINCT and ORDER BY
- Moved model-specific code into RDF::Query::Model::*
- Moving over to redland's query API (pass in the model when query is executed)

## Copyright

Copyright © 2005–2006 Gregory Williams. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

$Id: README.html 151 2006-06-04 20:08:40Z samofool $