Skip to content

postgres custom operators are not parsed correctly #372

Closed
apache/datafusion-sqlparser-rs
#1302
@amrutadotorg

Description

@amrutadotorg

Hi, is it possible to add support for PGroonga operators?

Here is the list of operators:
https://pgroonga.github.io/reference/

&@ operator: Full text search by a keyword
&@~ operator: Full text search by easy to use query language
&@* operator: Similar search
&` operator: Advanced search by ECMAScript like query language
&@| operator: Full text search by an array of keywords
&@~| operator: Full text search by an array of queries in easy to use query language

Currently, it seems like it does not work, or I might be doing something wrong.
Thank you.

SELECT 
    'list' AS component,
    'headline' AS id,
    'No posts found' as empty_title,
    'No posts found' as empty_description_md;

SELECT 
    post.id,
    pgroonga_highlight_html(post.content,pgroonga_query_extract_keywords($search)) AS description_md,
    translations.language_code
FROM 
    post
JOIN 
    translations ON translations.element_id = post.id
    AND translations.element_type = 'post_post'
    AND translations.language_code = 'en'
WHERE 
    post.content &@~ $search
LIMIT 5;
2024-06-03 05:02:19.187 CEST [10443] ERROR:  operator does not exist: @~ text at character 320
2024-06-03 05:02:19.187 CEST [10443] HINT:  No operator matches the given name and argument type. You might need to add an explicit type cast.
2024-06-03 05:02:19.187 CEST [10443] STATEMENT:  SELECT post.id, pgroonga_highlight_html(post.content, pgroonga_query_extract_keywords(CAST($1 AS TEXT))) AS description_md, translations.language_code FROM post JOIN translations ON translations.element_id = post.id AND translations.element_type = 'post_post' AND translations.language_code = 'en' WHERE post.content & @~CAST($2 AS TEXT) LIMIT 5;
test=# select count(*)
FROM
    post
JOIN
    translations ON translations.element_id = post.id
    AND translations.element_type = 'post_post'
WHERE
    post.content &@~ 'myślę'
LIMIT 5;
 count
-------
    16
(1 row)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions