Skip to content

Column alias is not working when retrieving JSON from Pandas DataFrame #5123

@sh19910711

Description

@sh19910711

What happens?

When reading a JSON string contained in a Pandas DataFrame, I tried to set a column alias on the extracted data, but it was ignored. It works as expected when I specify the JSON string directly.

To Reproduce

# Python 3.7.15
import duckdb # 0.5.2.dev1278:
import pandas as pd # 1.3.5

df_test = pd.DataFrame([{'json_str': '{"hello":"world"}'}])


print(duckdb.connect().execute('''
    select
        json(json_str)->'hello' as MISSING
    from
        df_test
''').df())
#   json(json_str) -> 'hello'
# 0                   "world"


print(duckdb.connect().execute('''
    select
        json('{"hello":"world"}')->'hello' as FOUND
''').df())
#      FOUND
# 0  "world"

OS:

Ubuntu 18.04.6 LTS

DuckDB Version:

0.5.1

DuckDB Client:

Python

Full Name:

Hiroyuki Sano

Affiliation:

University of Tsukuba

Have you tried this on the latest master branch?

  • I agree

Have you tried the steps to reproduce? Do they include all relevant data and configuration? Does the issue you report still appear there?

  • I agree

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions