Skip to content

Commit

Permalink
Parse Error UI Improvement (#3085)
Browse files Browse the repository at this point in the history
* Handle Error Case Differently
* Handle missing properties in query info
* Do not show the histogram if there is a parse error
* Loosen missing pool error detection
* Improve histogram error message
  • Loading branch information
jameskerr authored Jun 10, 2024
1 parent ad5657d commit 21abbf6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 12 deletions.
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

0 comments on commit 21abbf6

Please sign in to comment.