Skip to content

Commit

Permalink
Fixing preview data handling of big ints (#1950)
Browse files Browse the repository at this point in the history
Signed-off-by: Kristen Armes <karmes@lyft.com>
  • Loading branch information
kristenarmes authored Aug 2, 2022
1 parent a9aa1dd commit 55e886b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
4 changes: 2 additions & 2 deletions frontend/amundsen_application/static/.betterer.results
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,8 @@ exports[`eslint`] = {
[19, 2, 8, "Assignment to function parameter \'resource\'.", "2131237679"],
[20, 2, 248, "Expected a default case.", "1034339850"]
],
"js/ducks/tableMetadata/api/v0.ts:3505354085": [
[140, 23, -4358, "Expected to return a value at the end of arrow function.", "5381"]
"js/ducks/tableMetadata/api/v0.ts:2322129867": [
[142, 23, -4399, "Expected to return a value at the end of arrow function.", "5381"]
],
"js/ducks/tableMetadata/owners/index.spec.ts:655040122": [
[15, 0, 91, "\`../reducer\` import should occur before import of \`./reducer\`", "2216296793"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import {
getTypeMetadataFromKey,
} from './helpers';

const JSONBig = require('json-bigint');

export const API_PATH = '/api/metadata/v0';

type MessageAPI = { msg: string };
Expand Down Expand Up @@ -215,6 +217,7 @@ export function getPreviewData(queryParams: TablePreviewQueryParams) {
url: '/api/preview/v0/',
method: 'POST',
data: queryParams,
transformResponse: (data) => JSONBig.parse(data),
})
.then((response: AxiosResponse<PreviewDataAPI>) => ({
data: response.data.previewData,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {

import './styles.scss';

const JSONBig = require('json-bigint');

export interface PreviewDataProps {
isLoading: boolean;
previewData: PreviewData;
Expand All @@ -36,7 +38,7 @@ export const getSanitizedValue = (value) => {
if (value === 0 || typeof value === 'boolean') {
sanitizedValue = value.toString();
} else if (typeof value === 'object') {
sanitizedValue = JSON.stringify(value);
sanitizedValue = JSONBig.stringify(value);
} else if (typeof value === 'undefined') {
sanitizedValue = '';
} else {
Expand Down
27 changes: 20 additions & 7 deletions frontend/amundsen_application/static/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/amundsen_application/static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
"form-serialize": "^0.7.2",
"fsevents": "*",
"jquery": "^3.5.0",
"json-bigint": "^1.0.0",
"moment-timezone": "^0.5.33",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
Expand Down

0 comments on commit 55e886b

Please sign in to comment.