Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build_macos_arm64_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ jobs:
brew update
brew install ca-certificates lz4 mpdecimal openssl@3 readline sqlite xz z3 zstd
brew install --ignore-dependencies llvm@19
brew install git ccache ninja libtool gettext gcc binutils grep findutils nasm
brew install git ninja libtool gettext gcc binutils grep findutils nasm
brew install --build-from-source ccache
brew install go
cd /usr/local/opt/ && sudo rm -f llvm && sudo ln -sf llvm@19 llvm
export PATH=$(brew --prefix llvm@19)/bin:$PATH
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build_macos_x86_wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ jobs:
brew update
brew install ca-certificates lz4 mpdecimal openssl@3 readline sqlite xz z3 zstd
brew install --ignore-dependencies llvm@19
brew install git ccache ninja libtool gettext gcc binutils grep findutils nasm
brew install git ninja libtool gettext gcc binutils grep findutils nasm
brew install --build-from-source ccache
brew install go
cd /usr/local/opt/ && sudo rm -f llvm && sudo ln -sf llvm@19 llvm
export PATH=$(brew --prefix llvm@19)/bin:$PATH
Expand Down
2 changes: 1 addition & 1 deletion programs/local/PythonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const void * tryGetPyArray(const py::object & obj, py::handle & result, py::hand
// chdb todo: need more type check
if (row_count > 0)
{
auto elem_type = obj.attr("__getitem__")(0).attr("__class__").attr("__name__").cast<std::string>();
auto elem_type = obj.attr("iloc").attr("__getitem__")(0).attr("__class__").attr("__name__").cast<std::string>();
if (elem_type == "str" || elem_type == "unicode")
{
result = array;
Expand Down
34 changes: 34 additions & 0 deletions tests/test_query_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,40 @@ def test_query_df(self):
ret = chdb.query("SELECT b, sum(a) FROM Python(df) GROUP BY b ORDER BY b")
self.assertEqual(str(ret), EXPECTED)

def test_query_df_with_index(self):
df = pd.DataFrame(
{
"a": [1, 2, 3, 4, 5, 6],
"b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"],
},
index=[3, 1, 2, 4, 5, 6],
)

ret = chdb.query("SELECT * FROM Python(df)")
self.assertIn("tom", str(ret))

df = pd.DataFrame(
{
"a": [1, 2, 3, 4, 5, 6],
"b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"],
},
index=[0, 1, 2, 4, 5, 6],
)

ret = chdb.query("SELECT * FROM Python(df)")
self.assertIn("tom", str(ret))

df = pd.DataFrame(
{
"a": [1, 2, 3, 4, 5, 6],
"b": ["tom", "jerry", "auxten", "tom", "jerry", "auxten"],
},
index=['a', 1, 2, 4, 5, 6],
)

ret = chdb.query("SELECT * FROM Python(df)")
self.assertIn("tom", str(ret))

def test_query_arrow(self):
table = pa.table(
{
Expand Down
Loading