Skip to content

Commit aabfdff

Browse files
display column lineage JSON
Signed-off-by: Pawel Leszczynski <leszczynski.pawel@gmail.com>
1 parent a78f8ec commit aabfdff

10 files changed

Lines changed: 132 additions & 18 deletions

File tree

web/src/components/bottom-bar/BottomBar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class BottomBar extends React.Component<BottomBarProps> {
5454
<Box className={classes.overflow} height={bottomBarHeight}>
5555
<Container maxWidth={'lg'} disableGutters={true}>
5656
{lineageJob && <JobDetailPage job={lineageJob} />}
57-
{lineageDataset && <DatasetDetailPage dataset={lineageDataset} />}
57+
{lineageDataset && <DatasetDetailPage lineageDataset={lineageDataset} />}
5858
</Container>
5959
</Box>
6060
</Box>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
import { Box } from '@material-ui/core'
4+
import MqEmpty from '../core/empty/MqEmpty'
5+
import MqJson from '../core/code/MqJson'
6+
import React, { FunctionComponent } from 'react'
7+
8+
interface DatasetColumnLineageProps {
9+
columnLineage: object
10+
}
11+
12+
const DatasetColumnLineage: FunctionComponent<DatasetColumnLineageProps> = props => {
13+
const { columnLineage } = props
14+
15+
return (
16+
<Box>
17+
{columnLineage === null && <MqEmpty title={'No column lineage'} body={'Column lineage not available for the specified dataset.'} />}
18+
{columnLineage && (
19+
<Box mt={2}>
20+
<MqJson code={columnLineage} />
21+
</Box>
22+
)}
23+
</Box>
24+
)
25+
}
26+
27+
export default DatasetColumnLineage

web/src/components/datasets/DatasetDetailPage.tsx

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { ChangeEvent, FunctionComponent, SetStateAction, useEffect } from
44

55
import * as Redux from 'redux'
66
import { Box, Chip, Tab, Tabs } from '@material-ui/core'
7-
import { DatasetVersion } from '../../types/api'
7+
import { Dataset, DatasetVersion } from '../../types/api';
88
import { IState } from '../../store/reducers'
99
import {
1010
Theme as ITheme,
@@ -15,10 +15,15 @@ import {
1515
import { LineageDataset } from '../lineage/types'
1616
import { bindActionCreators } from 'redux'
1717
import { connect } from 'react-redux'
18-
import { fetchDatasetVersions, resetDatasetVersions } from '../../store/actionCreators'
18+
import {
19+
fetchDataset,
20+
fetchDatasetVersions,
21+
resetDatasetVersions
22+
} from '../../store/actionCreators'
1923
import { useHistory } from 'react-router-dom'
2024
import CircularProgress from '@material-ui/core/CircularProgress/CircularProgress'
2125
import CloseIcon from '@material-ui/icons/Close'
26+
import DatasetColumnLineage from './DatasetColumnLineage'
2227
import DatasetInfo from './DatasetInfo'
2328
import DatasetVersions from './DatasetVersions'
2429
import IconButton from '@material-ui/core/IconButton'
@@ -55,13 +60,15 @@ const styles = ({ spacing }: ITheme) => {
5560
}
5661

5762
interface StateProps {
58-
dataset: LineageDataset
63+
lineageDataset: LineageDataset
5964
versions: DatasetVersion[]
65+
dataset: Dataset
6066
versionsLoading: boolean
6167
}
6268

6369
interface DispatchProps {
6470
fetchDatasetVersions: typeof fetchDatasetVersions
71+
fetchDataset: typeof fetchDataset
6572
resetDatasetVersions: typeof resetDatasetVersions
6673
}
6774

@@ -75,13 +82,13 @@ function a11yProps(index: number) {
7582
}
7683

7784
const DatasetDetailPage: FunctionComponent<IProps> = props => {
78-
const { classes, fetchDatasetVersions, resetDatasetVersions, versions, versionsLoading } = props
85+
const { classes, fetchDatasetVersions, fetchDataset, resetDatasetVersions, versions, versionsLoading } = props
7986
const { root } = classes
8087
const history = useHistory()
8188

8289
useEffect(() => {
83-
fetchDatasetVersions(props.dataset.namespace, props.dataset.name)
84-
}, [props.dataset.name])
90+
fetchDatasetVersions(props.lineageDataset.namespace, props.lineageDataset.name)
91+
}, [props.lineageDataset.name])
8592

8693
// unmounting
8794
useEffect(() => {
@@ -90,6 +97,10 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
9097
}
9198
}, [])
9299

100+
// useEffect(() => {
101+
// fetchDataset(props.lineageDataset.namespace, props.lineageDataset.name)
102+
// }, [props.lineageDataset.name])
103+
93104
const [tab, setTab] = React.useState(0)
94105
const handleChange = (event: ChangeEvent, newValue: SetStateAction<number>) => {
95106
setTab(newValue)
@@ -107,8 +118,8 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
107118
return null
108119
}
109120

110-
const dataset = versions[0]
111-
const { name, tags, description } = dataset
121+
const firstVersion = versions[0]
122+
const { name, tags, description } = firstVersion
112123

113124
return (
114125
<Box my={2} className={root}>
@@ -127,6 +138,7 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
127138
<Tabs value={tab} onChange={handleChange} textColor='primary' indicatorColor='primary'>
128139
<Tab label='LATEST SCHEMA' {...a11yProps(0)} disableRipple={true} />
129140
<Tab label='VERSION HISTORY' {...a11yProps(1)} disableRipple={true} />
141+
<Tab label='COLUMN LINEAGE' {...a11yProps(2)} disableRipple={true} />
130142
</Tabs>
131143
</Box>
132144
<IconButton onClick={() => history.push('/datasets')}>
@@ -142,26 +154,29 @@ const DatasetDetailPage: FunctionComponent<IProps> = props => {
142154
</Box>
143155
{tab === 0 && (
144156
<DatasetInfo
145-
datasetFields={dataset.fields}
146-
facets={dataset.facets}
147-
run={dataset.createdByRun}
157+
datasetFields={firstVersion.fields}
158+
facets={firstVersion.facets}
159+
run={firstVersion.createdByRun}
148160
/>
149161
)}
150162
{tab === 1 && <DatasetVersions versions={props.versions} />}
163+
{tab === 2 && (props.dataset.name !== undefined || fetchDataset(props.lineageDataset.namespace, props.lineageDataset.name)) && <DatasetColumnLineage columnLineage={props.dataset.columnLineage} />}
151164
</Box>
152165
)
153166
}
154167

155168
const mapStateToProps = (state: IState) => ({
156169
datasets: state.datasets.result,
157170
versions: state.datasetVersions.result.versions,
171+
dataset: state.dataset.result,
158172
versionsLoading: state.datasetVersions.isLoading
159173
})
160174

161175
const mapDispatchToProps = (dispatch: Redux.Dispatch) =>
162176
bindActionCreators(
163177
{
164178
fetchDatasetVersions: fetchDatasetVersions,
179+
fetchDataset: fetchDataset,
165180
resetDatasetVersions: resetDatasetVersions
166181
},
167182
dispatch

web/src/store/actionCreators/actionTypes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ export const RESET_JOBS = 'RESET_JOBS'
2222

2323
// datasets
2424
export const FETCH_DATASETS = 'FETCH_DATASETS'
25+
export const FETCH_DATASET = 'FETCH_DATASET'
2526
export const FETCH_DATASETS_SUCCESS = 'FETCH_DATASETS_SUCCESS'
27+
export const FETCH_DATASET_SUCCESS = 'FETCH_DATASET_SUCCESS'
2628
export const RESET_DATASETS = 'RESET_DATASETS'
29+
export const RESET_DATASET = 'RESET_DATASET'
2730
export const FETCH_DATASET_VERSIONS = 'FETCH_DATASET_VERSIONS'
2831
export const FETCH_DATASET_VERSIONS_SUCCESS = 'FETCH_DATASET_VERSIONS_SUCCESS'
2932
export const RESET_DATASET_VERSIONS = 'RESET_DATASET_VERSIONS'

web/src/store/actionCreators/index.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ export const fetchDatasetsSuccess = (datasets: Dataset[]) => ({
3939
}
4040
})
4141

42+
export const fetchDataset = (namespace: string, name: string) => ({
43+
type: actionTypes.FETCH_DATASET,
44+
payload: {
45+
namespace,
46+
name
47+
}
48+
})
49+
50+
export const fetchDatasetSuccess = (dataset: Dataset) => ({
51+
type: actionTypes.FETCH_DATASET_SUCCESS,
52+
payload: {
53+
dataset
54+
}
55+
})
56+
4257
export const fetchDatasetVersions = (namespace: string, name: string) => ({
4358
type: actionTypes.FETCH_DATASET_VERSIONS,
4459
payload: {

web/src/store/reducers/dataset.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
import { Dataset } from '../../types/api'
4+
import {
5+
FETCH_DATASET,
6+
FETCH_DATASET_SUCCESS,
7+
RESET_DATASET
8+
} from '../actionCreators/actionTypes'
9+
import { fetchDatasetSuccess } from '../actionCreators';
10+
11+
export type IDatasetState = { isLoading: boolean; result: Dataset; init: boolean }
12+
13+
export const initialState: IDatasetState = { isLoading: false, init: false, result: { } as Dataset }
14+
15+
type IDatasetAction = ReturnType<typeof fetchDatasetSuccess>
16+
17+
export default (state: IDatasetState = initialState, action: IDatasetAction): IDatasetState => {
18+
const { type, payload } = action
19+
20+
switch (type) {
21+
case FETCH_DATASET:
22+
return { ...state, isLoading: true }
23+
case FETCH_DATASET_SUCCESS:
24+
return { ...state, isLoading: false, init: true, result: payload.dataset }
25+
case RESET_DATASET:
26+
return initialState
27+
default:
28+
return state
29+
}
30+
}

web/src/store/reducers/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { History } from 'history'
44
import { Reducer, combineReducers } from 'redux'
55
import { connectRouter } from 'connected-react-router'
6+
import dataset, { IDatasetState } from './dataset';
67
import datasetVersions, { IDatasetVersionsState } from './datasetVersions'
78
import datasets, { IDatasetsState } from './datasets'
89
import events, { IEventsState } from './events'
@@ -15,6 +16,7 @@ import search, { ISearchState } from './search'
1516

1617
export interface IState {
1718
datasets: IDatasetsState
19+
dataset: IDatasetState
1820
datasetVersions: IDatasetVersionsState
1921
events: IEventsState
2022
jobs: IJobsState
@@ -29,6 +31,7 @@ export interface IState {
2931
export default (history: History): Reducer =>
3032
combineReducers({
3133
router: connectRouter(history),
34+
dataset,
3235
datasets,
3336
datasetVersions,
3437
events,

web/src/store/requests/datasets.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: Apache-2.0
22

33
import { API_URL } from '../../globals'
4-
import { DatasetVersions, Datasets } from '../../types/api'
4+
import { Dataset, DatasetVersions, Datasets } from "../../types/api";
55
import { genericFetchWrapper } from './index'
66

77
export const getDatasets = async (namespace: string, limit = 25, offset = 0) => {
@@ -26,3 +26,10 @@ export const getDatasetVersions = async (
2626
(versions: DatasetVersions) => versions.versions
2727
)
2828
}
29+
30+
export const getDataset = async (namespace: string, dataset: string) => {
31+
const url = `${API_URL}/namespaces/${encodeURIComponent(namespace)}/datasets/${encodeURIComponent(
32+
dataset
33+
)}`
34+
return genericFetchWrapper(url, { method: 'GET' }, 'fetchDataset').then((d: Dataset) => d)
35+
}

web/src/store/sagas/index.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
FETCH_LINEAGE,
99
FETCH_RUNS,
1010
FETCH_SEARCH,
11-
FETCH_EVENTS
12-
} from '../actionCreators/actionTypes'
11+
FETCH_EVENTS, FETCH_DATASET
12+
} from "../actionCreators/actionTypes";
1313
import { Namespaces } from '../../types/api'
1414
import { all, put, take } from 'redux-saga/effects'
1515

@@ -24,9 +24,9 @@ import {
2424
fetchLineageSuccess,
2525
fetchNamespacesSuccess,
2626
fetchRunsSuccess,
27-
fetchSearchSuccess
28-
} from '../actionCreators'
29-
import { getDatasetVersions, getDatasets, getEvents, getJobs, getNamespaces, getRuns } from '../requests'
27+
fetchSearchSuccess, fetchDatasetSuccess
28+
} from "../actionCreators";
29+
import { getDatasetVersions, getDatasets, getDataset, getEvents, getJobs, getNamespaces, getRuns } from '../requests'
3030
import { getLineage } from '../requests/lineage'
3131
import { getSearch } from '../requests/search'
3232

@@ -112,6 +112,18 @@ export function* fetchEventsSaga() {
112112
}
113113
}
114114

115+
export function* fetchDatasetSaga() {
116+
while (true) {
117+
try {
118+
const { payload } = yield take(FETCH_DATASET)
119+
const datasets = yield call(getDataset, payload.namespace, payload.name)
120+
yield put(fetchDatasetSuccess(datasets))
121+
} catch (e) {
122+
yield put(applicationError('Something went wrong while fetching dataset'))
123+
}
124+
}
125+
}
126+
115127
export function* fetchDatasetVersionsSaga() {
116128
while (true) {
117129
try {
@@ -130,6 +142,7 @@ export default function* rootSaga(): Generator {
130142
fetchJobsSaga(),
131143
fetchRunsSaga(),
132144
fetchDatasetsSaga(),
145+
fetchDatasetSaga(),
133146
fetchDatasetVersionsSaga(),
134147
fetchEventsSaga(),
135148
fetchLineage(),

web/src/types/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export interface Dataset {
7272
description: string
7373
facets: object
7474
deleted: boolean
75+
columnLineage: object
7576
}
7677

7778
export interface DatasetVersions {

0 commit comments

Comments
 (0)