What's a dialect?
A dialect defines how Pentaho Metadata should generate SQL for a given database type.
Metadata's Dialect Plugin System (SPI)
Introduced in release 3.7 Pentaho Metadata supports additional dialects through it's Service Provider Interface (SPI): SQLDialectInterface
. A Pentaho Metadata Dialect Plugin is a jar file that consists of a dialect implementation and some configuration. The SPI enables developers to develop new database dialects which Pentaho Metadata will automatically detect and register.
Implementing SQLDialectInterface
Declaring your Dialect as a Service Provider
Pentaho Metdata utilizes the Java Service Loader API to dynamically look up dialect implementations. The ServiceLoader API requires you list all Service Provider implementations in a file named after the interface of the service they provide in the META-INF/services
directory of the jar file:
META-INF/services/org.pentaho.pms.mql.dialect.SQLDialectInterface: org.pentaho.pms.mql.dialect.SampleDialect
Where org.pentaho.pms.mql.dialect.SampleDialect
is the implementation of META-INF/services/org.pentaho.pms.mql.dialect.SQLDialectInterface
for our Sample database type.
To define a Pentaho Metadata Dialect you must implement org.pentaho.pms.mql.SQLDialectInterface and define the implementation as a Service Provider[1].
For more information see Jar Service Provider Packaging Notes from Oracle.
Using your plugin
All that is required is the jar file to be in the classpath. In most applications this is a /lib
directory within the application's installation directory.
For more general information about Java's ServiceLoader API see these links:
http://download.oracle.com/javase/6/docs/api/java/util/ServiceLoader.html
http://java.sun.com/developer/technicalArticles/javase/extensible/index.html