---
name: "RDF::Query::Compiler::SQL"
section: "3pm"
platform: "linux"
package: "librdf-query-perl"
version: "2.919-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/RDF::Query::Compiler::SQL"
---

# RDF::Query::Compiler::SQL(3pm)

Compile a SPARQL query directly to SQL.

## NAME

RDF::Query::Compiler::SQL - Compile a SPARQL query directly to SQL.

## VERSION

This document describes RDF::Query::Compiler::SQL version 2.919.

## STATUS

This module's API and functionality should be considered deprecated. If you need functionality that this module provides, please get in touch \<http://www.perlrdf.org/\>.

## METHODS

- "new ( $parse\_tree )"

  Returns a new compiler object.

- "compile ()"

  Returns a SQL query string for the specified parse tree.

- "emit\_select"

  Returns a SQL query string representing the query.

- "limit\_clause"

  Returns a SQL LIMIT clause, or an empty string if the query does not need limiting.

- "order\_by\_clause"

  Returns a SQL ORDER BY clause, or an empty string if the query does not use ordering.

- "variable\_columns ( $var )"

  Given a variable name, returns the set of column aliases that store the values for the column (values for Literals, URIs, and Blank Nodes).

- "add\_variable\_values\_joins"

  Modifies the query by adding LEFT JOINs to the tables in the database that contain the node values (for literals, resources, and blank nodes).

- "patterns2sql ( \\@triples, \\$level, %args )"

  Builds the SQL query in instance data from the supplied `@triples`. `$level` is used as a unique identifier for recursive calls.

  `%args` may contain callback closures for the following keys:

  ```
    'where_hook'
    'from_hook'
  ```

  When present, these closures are used to add SQL FROM and WHERE clauses to the query instead of adding them directly to the object's instance data.

- "expr2sql ( $expression, \\$level, %args )"

  Returns a SQL expression for the supplied query `$expression`. `$level` is used as a unique identifier for recursive calls.

  `%args` may contain callback closures for the following keys:

  ```
    'where_hook'
    'from_hook'
  ```

  When present, these closures are used to add necessary SQL FROM and WHERE clauses to the query.

- "\_mysql\_hash ( $data )"

  Returns a hash value for the supplied `$data` string. This value is computed using the same algorithm that Redland's mysql storage backend uses.

- "\_mysql\_node\_hash ( $node )"

  Returns a hash value (computed by `"_mysql_hash"` for the supplied `$node`. The hash value is based on the string value of the node and the node type.

- "qualify\_uri ( $uri )"

  Returns a fully qualified URI from the supplied `$uri`. `$uri` may already be a qualified URI, or a parse tree for a qualified URI or QName. If `$uri` is a QName, the namespaces defined in the query parse tree are used to fully qualify.

- "add\_function ( $uri, $function )"

  Associates the custom function `$function` (a CODE reference) with the specified URI, allowing the function to be called by query FILTERs.

- "get\_function ( $uri )"

  If `$uri` is associated with a query function, returns a CODE reference to the function. Otherwise returns `"undef"`.

## AUTHOR

```
 Gregory Williams <gwilliams@cpan.org>
```
