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

Kamu 180 add ability to rename and to delete dataset #120

Merged
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: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ build
coverage
node_modules
dist

/resources/schema.graphql
*.md
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased
### Added
- Deleting and renaming a dataset on Settings tab
- Added icons for dataset's tabs

## [0.8.0] - 2023-08-04
### Added
- Added pictures in the dropdown list for engines
Expand Down Expand Up @@ -56,6 +61,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [0.4.0] - 2022-11-18
### Added

- Keeping a CHANGELOG!
- Major refactorings and productization of the web UI

101 changes: 57 additions & 44 deletions resources/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ type DataQueries {
queryDialect: QueryDialect!
dataFormat: DataBatchFormat
schemaFormat: DataSchemaFormat
skip: Int
limit: Int
): DataQueryResult!
"""
Expand Down Expand Up @@ -220,6 +221,8 @@ type Dataset {
lastUpdatedAt: DateTime!
}

scalar DatasetAlias

type DatasetConnection {
"""
A shorthand for `edges { node { ... } }`
Expand Down Expand Up @@ -251,11 +254,7 @@ type DatasetData {
This is equivalent to the SQL query: `SELECT * FROM dataset ORDER BY
event_time DESC LIMIT N`
"""
tail(
limit: Int
dataFormat: DataBatchFormat
schemaFormat: DataSchemaFormat
): DataQueryResult!
tail(skip: Int, limit: Int, dataFormat: DataBatchFormat, schemaFormat: DataSchemaFormat): DataQueryResult!
}

type DatasetEdge {
Expand Down Expand Up @@ -333,10 +332,20 @@ type DatasetMut {
Access to the mutable metadata of the dataset
"""
metadata: DatasetMetadataMut!
"""
Rename the dataset
"""
rename(newName: DatasetName!): RenameResult!
"""
Delete the dataset
"""
delete: DeleteResult!
}

scalar DatasetName

scalar DatasetRef

scalar DatasetRefAny

type Datasets {
Expand All @@ -351,19 +360,11 @@ type Datasets {
"""
Returns datasets belonging to the specified account
"""
byAccountId(
accountId: AccountID!
page: Int
perPage: Int
): DatasetConnection!
byAccountId(accountId: AccountID!, page: Int, perPage: Int): DatasetConnection!
"""
Returns datasets belonging to the specified account
"""
byAccountName(
accountName: AccountName!
page: Int
perPage: Int
): DatasetConnection!
byAccountName(accountName: AccountName!, page: Int, perPage: Int): DatasetConnection!
}

type DatasetsMut {
Expand All @@ -374,11 +375,7 @@ type DatasetsMut {
"""
Creates a new empty dataset
"""
createEmpty(
accountId: AccountID!
datasetKind: DatasetKind!
datasetName: DatasetName!
): CreateDatasetResult!
createEmpty(accountId: AccountID!, datasetKind: DatasetKind!, datasetName: DatasetName!): CreateDatasetResult!
"""
Creates a new dataset from provided DatasetSnapshot manifest
"""
Expand All @@ -396,6 +393,21 @@ The input/output is a string in RFC3339 format.
"""
scalar DateTime

interface DeleteResult {
message: String!
}

type DeleteResultDanglingReference implements DeleteResult {
notDeletedDataset: DatasetAlias!
danglingChildRefs: [DatasetRef!]!
message: String!
}

type DeleteResultSuccess implements DeleteResult {
deletedDataset: DatasetAlias!
message: String!
}

"""
Describes
"""
Expand Down Expand Up @@ -475,10 +487,7 @@ type LoginResponse {
accountInfo: AccountInfo!
}

union MergeStrategy =
MergeStrategyAppend
| MergeStrategyLedger
| MergeStrategySnapshot
union MergeStrategy = MergeStrategyAppend | MergeStrategyLedger | MergeStrategySnapshot

type MergeStrategyAppend {
dummy: String
Expand Down Expand Up @@ -550,10 +559,7 @@ type MetadataChainMut {
"""
Commits new event to the metadata chain
"""
commitEvent(
event: String!
eventFormat: MetadataManifestFormat!
): CommitResult!
commitEvent(event: String!, eventFormat: MetadataManifestFormat!): CommitResult!
}

union MetadataEvent =
Expand Down Expand Up @@ -697,12 +703,7 @@ enum QueryDialect {
SQL_DATA_FUSION
}

union ReadStep =
ReadStepCsv
| ReadStepJsonLines
| ReadStepGeoJson
| ReadStepEsriShapefile
| ReadStepParquet
union ReadStep = ReadStepCsv | ReadStepJsonLines | ReadStepGeoJson | ReadStepEsriShapefile | ReadStepParquet

type ReadStepCsv {
schema: [String!]
Expand Down Expand Up @@ -748,6 +749,26 @@ type ReadStepParquet {
schema: [String!]
}

interface RenameResult {
message: String!
}

type RenameResultNameCollision implements RenameResult {
collidingAlias: DatasetAlias!
message: String!
}

type RenameResultNoChanges implements RenameResult {
preservedName: DatasetName!
message: String!
}

type RenameResultSuccess implements RenameResult {
oldName: DatasetName!
newName: DatasetName!
message: String!
}

type RequestHeader {
name: String!
value: String!
Expand Down Expand Up @@ -951,11 +972,7 @@ type Tasks {
Returns states of tasks associated with a given dataset ordered by
creation time from newest to oldest
"""
listTasksByDataset(
datasetId: DatasetID!
page: Int
perPage: Int
): TaskConnection!
listTasksByDataset(datasetId: DatasetID!, page: Int, perPage: Int): TaskConnection!
}

type TasksMut {
Expand All @@ -972,11 +989,7 @@ type TasksMut {
Schedules a task to update the specified dataset by performing polling
ingest or a derivative transformation
"""
createProbeTask(
datasetId: DatasetID
busyTimeMs: Int
endWithOutcome: TaskOutcome
): Task!
createProbeTask(datasetId: DatasetID, busyTimeMs: Int, endWithOutcome: TaskOutcome): Task!
}

type TemporalTable {
Expand Down
33 changes: 33 additions & 0 deletions src/app/api/dataset.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ import {
DatasetByAccountAndDatasetNameGQL,
DatasetByAccountAndDatasetNameQuery,
DatasetKind,
DeleteDatasetGQL,
DeleteDatasetMutation,
GetDatasetSchemaGQL,
GetDatasetSchemaQuery,
RenameDatasetGQL,
RenameDatasetMutation,
UpdateReadmeGQL,
UpdateReadmeMutation,
} from "src/app/api/kamu.graphql.interface";
Expand Down Expand Up @@ -51,6 +55,8 @@ export class DatasetApi {
private commitEventToDatasetGQL: CommitEventToDatasetGQL,
private datasetSchemaGQL: GetDatasetSchemaGQL,
private updateReadmeGQL: UpdateReadmeGQL,
private deleteDatasetGQL: DeleteDatasetGQL,
private renameDatasetGQL: RenameDatasetGQL,
) {}

public getDatasetMainData(params: {
Expand Down Expand Up @@ -238,4 +244,31 @@ export class DatasetApi {
}),
);
}

public deleteDataset(datasetId: string): Observable<DeleteDatasetMutation | null | undefined> {
return this.deleteDatasetGQL
.mutate({
datasetId,
})
.pipe(
first(),
map((result: MutationResult<DeleteDatasetMutation>) => {
return result.data;
}),
);
}

public renameDataset(datasetId: string, newName: string): Observable<RenameDatasetMutation | null | undefined> {
return this.renameDatasetGQL
.mutate({
datasetId,
newName,
})
.pipe(
first(),
map((result: MutationResult<RenameDatasetMutation>) => {
return result.data;
}),
);
}
}
17 changes: 17 additions & 0 deletions src/app/api/gql/delete-dataset/delete-dataset.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
mutation deleteDataset($datasetId: DatasetID!) {
datasets {
byId(datasetId: $datasetId) {
delete {
... on DeleteResultDanglingReference {
message
danglingChildRefs
notDeletedDataset
}
... on DeleteResultSuccess {
message
deletedDataset
}
}
}
}
}
22 changes: 22 additions & 0 deletions src/app/api/gql/rename-dataset/rename-dataset.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
mutation renameDataset($datasetId: DatasetID!, $newName: DatasetName!) {
datasets {
byId(datasetId: $datasetId) {
rename(newName: $newName) {
__typename
... on RenameResultSuccess {
message
oldName
newName
}
... on RenameResultNoChanges {
preservedName
message
}
... on RenameResultNameCollision {
message
collidingAlias
}
}
}
}
}
Loading
Loading