Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Error UI Improvement #3085

Merged
merged 5 commits into from
Jun 10, 2024
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
13 changes: 9 additions & 4 deletions apps/zui/src/js/state/QueryInfo/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ export const get = activeTabSelect((tab) => {
export const getParseError = createSelector(get, (info) => info.error)
export const getIsParsed = createSelector(get, (info) => info.isParsed)
export const getPoolName = createSelector(get, (info) => {
let source = find(info.sources, {kind: "Pool"})
let source = find(info.sources || [], {kind: "Pool"})
return source ? source.name : null
})
export const getGroupByKeys = createSelector(get, (info) => {
return info.channels[0].aggregation_keys
const {channels} = info
if (channels) {
return channels[0].aggregation_keys || []
} else {
return []
}
})
export const hasAggregation = createSelector(get, (info) => {
return !!info.channels[0].aggregation_keys
export const hasAggregation = createSelector(getGroupByKeys, (keys) => {
return keys.length > 0
})
1 change: 0 additions & 1 deletion apps/zui/src/models/browser-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class BrowserTab extends DomainModel<Attrs> {
this.history.index = -1
}
this.history.push(pathname)
console.log(this.history)
}
}

Expand Down
4 changes: 3 additions & 1 deletion apps/zui/src/views/histogram-pane/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import {Toolbar} from "src/components/toolbar"
import {Title} from "./title"
import {Resizer} from "./resizer"
import {useRef} from "react"
import QueryInfo from "src/js/state/QueryInfo"

export function HistogramPane() {
const {Parent, width = 0, height = 0} = useParentSize()
const show = useSelector(Layout.getShowHistogram)
const chartHeight = useSelector(Layout.getChartHeight)
const parseError = useSelector(QueryInfo.getParseError)
const ref = useRef<HTMLDivElement>()
if (!show) return null
if (!show || parseError) return null

return (
<div
Expand Down
4 changes: 3 additions & 1 deletion apps/zui/src/views/histogram-pane/run-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ export const runHistogramQuery = createHandler(
async function getPoolRange() {
const queryText = `from ${poolId} | min(${timeField}), max(${timeField})`
const resp = await query(queryText, {signal})
const [{min, max}] = await resp.js()
const data = await resp.js()
if (data.length == 0) return null
const [{min, max}] = data
if (!(min instanceof Date && max instanceof Date)) return null
return [min, max] as [Date, Date]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const Card = styled.section`
`

export function isMissingPoolError(e: unknown) {
return e === "no pool name given"
return typeof e === "string" && /no pool name given/.test(e)
}

function PoolsList({pools}: {pools: Pool[]}) {
Expand Down
6 changes: 2 additions & 4 deletions apps/zui/src/views/session-page/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,16 @@ export class SessionPageHandler extends ViewHandler {
const history = this.select(Current.getHistory)

fetchQueryInfo(program).then((info) => {
if (info.error) {
return
}
this.dispatch(QueryInfo.set({isParsed: true, ...info}))
const poolName = this.select(QueryInfo.getPoolName)
this.invoke("updatePluginSessionOp", {poolName, program})
const pool = this.select(Pools.getByName(lakeId, poolName))

if (pool && !pool.hasSpan()) {
this.dispatch(syncPool(pool.id, lakeId))
}

if (history.action === "PUSH") {
if (!info.error && history.action === "PUSH") {
session.pushHistory()
}
})
Expand Down
Loading