-
Notifications
You must be signed in to change notification settings - Fork 172
support column exclusion for mongodb #3751
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
Open
jgao54
wants to merge
1
commit into
main
Choose a base branch
from
mongo-filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| 'use client'; | ||
| import { | ||
| Dispatch, | ||
| SetStateAction, | ||
| useCallback, | ||
| useMemo, | ||
| useState, | ||
| } from 'react'; | ||
|
|
||
| import { TableMapRow } from '@/app/dto/MirrorsDTO'; | ||
| import { Checkbox } from '@/lib/Checkbox'; | ||
| import { Label } from '@/lib/Label'; | ||
| import { RowWithCheckbox } from '@/lib/Layout'; | ||
| import { TextField } from '@/lib/TextField'; | ||
|
|
||
| interface SkipJsonFieldsProps { | ||
| tableRow: TableMapRow; | ||
| setRows: Dispatch<SetStateAction<TableMapRow[]>>; | ||
| } | ||
|
|
||
| const MONGODB_DOC_COLUMN_PREFIX = 'doc.'; | ||
|
|
||
| export default function SkipJsonFields({ | ||
| tableRow, | ||
| setRows, | ||
| }: SkipJsonFieldsProps) { | ||
| const existingExclude = useMemo(() => { | ||
| return Array.from(tableRow.exclude) | ||
| .filter((field) => field.startsWith(MONGODB_DOC_COLUMN_PREFIX)) | ||
| .map((field) => field.slice(MONGODB_DOC_COLUMN_PREFIX.length)) | ||
| .join(','); | ||
| }, [tableRow.exclude]); | ||
|
|
||
| const [showExclude, setShowExclude] = useState( | ||
| Array.from(tableRow.exclude).some((f) => | ||
| f.startsWith(MONGODB_DOC_COLUMN_PREFIX) | ||
| ) | ||
| ); | ||
| const [excludeValue, setExcludeValue] = useState(existingExclude); | ||
|
|
||
| const updateExclude = useCallback( | ||
| (value: string) => { | ||
| const fields = value | ||
| .split(',') | ||
| .map((f) => f.trim()) | ||
| .filter((f) => f !== '') | ||
| .map((f) => MONGODB_DOC_COLUMN_PREFIX + f); | ||
|
|
||
| setRows((prev) => | ||
| prev.map((row) => { | ||
| if (row.source !== tableRow.source) return row; | ||
| return { | ||
| ...row, | ||
| exclude: new Set(fields), | ||
| }; | ||
| }) | ||
| ); | ||
| }, | ||
| [tableRow.source, setRows] | ||
| ); | ||
|
|
||
| const handleToggle = useCallback( | ||
| (state: boolean) => { | ||
| setShowExclude(state); | ||
| if (!state) { | ||
| setExcludeValue(''); | ||
| updateExclude(''); | ||
| } | ||
| }, | ||
| [updateExclude] | ||
| ); | ||
|
|
||
| const handleChange = useCallback( | ||
| (value: string) => { | ||
| setExcludeValue(value); | ||
| updateExclude(value); | ||
| }, | ||
| [updateExclude] | ||
| ); | ||
|
|
||
| return ( | ||
| <div | ||
| style={{ | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| rowGap: '0.5rem', | ||
| }} | ||
| > | ||
| <div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}> | ||
| <RowWithCheckbox | ||
| label={ | ||
| <Label as='label' style={{ fontSize: 13 }}> | ||
| Hide sensitive fields | ||
| </Label> | ||
| } | ||
| action={ | ||
| <Checkbox | ||
| style={{ marginLeft: 0 }} | ||
| checked={showExclude} | ||
| onCheckedChange={handleToggle} | ||
| /> | ||
| } | ||
| /> | ||
| </div> | ||
| {showExclude && ( | ||
| <TextField | ||
| variant='simple' | ||
| placeholder='password,user.ssn,metadata.secret' | ||
| value={excludeValue} | ||
| onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
| handleChange(e.target.value) | ||
| } | ||
| /> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the other source types excluded columns are defined to be on the source side. Would it be difficult to do the same here and add
doc.(or another flattened column) in Go code?Also, seems like the
ssnand such would still end up in the raw table, if we expose it in e2e clickpipes, wouldn't the expectation be that it never lands in CH in the open?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, was thinking about how we'd want to extend this to other DBs -- in which case we'd need to pass info about which column the field exclusion is for from the client; but it feels a bit premature to worry about that given JSON is not currently supported for PG/MySQL, and even if we do support JSON for these sources, JSON field exclusion seems like a niche-enough use case that we could defer for some time.
re: sensitive data in raw table. two ways to work around it I originally had in mind was to document that doesn't require changes on our end (1) user explicitly add TTL to raw table (2) lock down permissions for raw table so it's only accessed by admin. That said, i think it might not be too tricky to just do exclusion properly, and in a way that is re-usable by flattened mode. Will explore this a bit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mongo column exclusion seems like a mirror of the existing "excluded columns" feature - so from the product point of view if we make it work just for Mongo it's plenty good as others already have it.