Skip to content

Fix GETPART function implementation in base transform binding #403

@john-sanchez31

Description

@john-sanchez31

The behavior of GETPART when there is nothing in the original string after the delimiter is currently inconsistent between the ansi/sqlite implementation versus what other dialects to akin to the Snowflake SPLIT_PART function (which GETPART is based on)

The current implementation of GETPART in the ansi/sqlite translation compared to GETPART in MySQL and Snowflake is as follow:

GETPART ANSI/SQLITE MySQL/SnowFlake
GETPART("string", "string", 1) -> "" ""
GETPART("string", "string", 2) -> None ""
GETPART("string", "string", 3) -> None None
GETPART("hello.world.", ".", 1) -> "hello" "hello"
GETPART("hello.world.", ".", 2) -> "world" "world"
GETPART("hello.world.", ".", 3) -> None ""
GETPART("hello.world.", ".", -1) -> None ""
GETPART("hello.world.", ".", -2) -> "world" "world"
GETPART("hello.world.", ".", -3) -> "hello" "hello"
GETPART("abab", "ab", 1) -> "" ""
GETPART("abab", "ab", 2) -> "" ""
GETPART("abab", "ab", 3) -> None ""
GETPART("abab", "ab", -1) -> None ""
GETPART("abab", "ab", -2) -> "" ""
GETPART("abab", "ab", -3) -> "" ""

The desire behavior for the ansi/sqlite GETPART to maintain consistency through the dialects is the behavior of the MySQL/Snowflake implementation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeffort - mediummid-sized issue with average implementation time/difficultyenhancementNew feature or requesttestingAlters the testing/CI process for PyDough

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions