Danny.an
Danny.an

Reputation: 47

Is there a Druid SQL Dialect?

I'm using Spring Data JPA with druid.

I added dependencies spring-boot-starter-data-jpa and avatica-core to use druid JDBC Driver with spring data jpa in my project.

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.calcite.avatica</groupId>
            <artifactId>avatica-core</artifactId>
            <version>${avatica.version}</version>
        </dependency>

And set properties like this.

spring.datasource.url=jdbc:avatica:remote:url=http://localhost:8888/druid/v2/sql/avatica/
spring.datasource.driver-class-name=org.apache.calcite.avatica.remote.Driver
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

Finally, I checked that querying druid sql works well.

@Repository
public interface SampleRepository extends JpaRepository<SampleEntity, String> {

    @Query(
        value = "SELECT w.page as page, count(w.page) as cnt " +
            "FROM wikipedia w " +
            "GROUP BY w.page " +
            "ORDER BY cnt DESC " +
            "LIMIT 10",
        nativeQuery = true
    )
    List<PageCount> findPageCountTopN();

But, I wonder that there's a jpa dialect for Druid SQL.

In official document of Druid SQL, no information about druid sql dialect.

As you see, there's no issue for using MySQL8Dialect and it works well.

But, in case an unexpected problem may arise, I'd like to apply it if there is such a thing.

Upvotes: 1

Views: 735

Answers (1)

user17936657
user17936657

Reputation: 131

I wonder that there's a jpa dialect for Druid SQL?

Druid dialect is +/- ANSI SQL. It adds some features and removes some features, but doesn't do anything divergent in area of functional overlap. If there is a JPA dialect for ANSI SQL then it should work.

Upvotes: 1

Related Questions