Skip to content

Read string as Utf8View in sqllogictest #13408

Open
@jayzhan211

Description

@jayzhan211

Is your feature request related to a problem or challenge?

This is the simplest way to create a string column

statement ok
create table t(a varchar) as values ('1'), ('2');

query T
select arrow_typeof(a) from t;
----
Utf8
Utf8

statement ok
drop table t

I'm finding a simple way to create Utf8View column. We can achieve this with casting (See datafusion/sqllogictest/test_files/string/string_view.slt) but I think we can have a more simpler way to do this.

Describe the solution you'd like

I have two idea but not sure which one is better

Approach 1

Set the configuration with use_string_view = true, and we will read the column (varchar) as string view type instead of string type.

Something like

set datafusion.xxx.use_string_view = true

statement ok
create table t(a varchar) as values ('1'), ('2');

query T
select arrow_typeof(a) from t;
----
Utf8View
Utf8View

statement ok
drop table t

This avoid adding new syntax.

Approach 2

introduce string_view syntax like varchar_view so we know we want to read it as string view type

Something like

statement ok
create table t(a varchar_view) as values ('1'), ('2');

query T
select arrow_typeof(a) from t;
----
Utf8View
Utf8View

statement ok
drop table t

This adds complexity of understanding of string view type for people from Postgres.

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions