Spaces:
Running
Running
Tony Powell
commited on
Commit
·
6f88283
1
Parent(s):
9131491
Fix empty table state
Browse files- src/table.tsx +9 -2
- src/useParquetTable.ts +1 -1
src/table.tsx
CHANGED
@@ -12,9 +12,16 @@ interface TableProps {
|
|
12 |
}
|
13 |
|
14 |
export const Table: React.FC<TableProps> = ({ data }) => {
|
15 |
-
const headers = useMemo(
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
-
if (data.length === 0)
|
|
|
18 |
|
19 |
return (
|
20 |
<table className="text-xs">
|
|
|
12 |
}
|
13 |
|
14 |
export const Table: React.FC<TableProps> = ({ data }) => {
|
15 |
+
const headers = useMemo(
|
16 |
+
() =>
|
17 |
+
data.length > 0 && typeof data[0] === "object"
|
18 |
+
? Object.keys(data[0])
|
19 |
+
: [],
|
20 |
+
[data]
|
21 |
+
);
|
22 |
|
23 |
+
if (data.length === 0)
|
24 |
+
return <div className="text-center p-8 font-mono">no data for query</div>;
|
25 |
|
26 |
return (
|
27 |
<table className="text-xs">
|
src/useParquetTable.ts
CHANGED
@@ -6,7 +6,7 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|
6 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7 |
const arrowResultToJson = (arrowResult: any) => {
|
8 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
9 |
-
return arrowResult.toArray().map((row: any) => row.toJSON());
|
10 |
};
|
11 |
|
12 |
export const useParquetTable = (
|
|
|
6 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
7 |
const arrowResultToJson = (arrowResult: any) => {
|
8 |
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
9 |
+
return arrowResult.toArray().map((row: any) => row.toJSON()) || [];
|
10 |
};
|
11 |
|
12 |
export const useParquetTable = (
|