-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fixes #27162: table version history shows current datatype instead of historical one #27478
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
base: main
Are you sure you want to change the base?
Changes from 4 commits
b2ee2a7
e5bb63c
3a523f0
b76028b
0bc5ac7
d4475c5
2c4882f
640ab1a
c8fc9f4
b5d3ddf
321ecb3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,11 +32,6 @@ import { | |||||||||||||||||||||||||||||||||
| import { Operation } from '../../../generated/entity/policies/policy'; | ||||||||||||||||||||||||||||||||||
| import { TagSource } from '../../../generated/type/tagLabel'; | ||||||||||||||||||||||||||||||||||
| import { usePaging } from '../../../hooks/paging/usePaging'; | ||||||||||||||||||||||||||||||||||
| import { useFqn } from '../../../hooks/useFqn'; | ||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||
| getTableColumnsByFQN, | ||||||||||||||||||||||||||||||||||
| searchTableColumnsByFQN, | ||||||||||||||||||||||||||||||||||
| } from '../../../rest/tableAPI'; | ||||||||||||||||||||||||||||||||||
| import { getPartialNameFromTableFQN } from '../../../utils/CommonUtils'; | ||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||
| getColumnsDataWithVersionChanges, | ||||||||||||||||||||||||||||||||||
|
|
@@ -89,7 +84,6 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |||||||||||||||||||||||||||||||||
| paging, | ||||||||||||||||||||||||||||||||||
| handlePagingChange, | ||||||||||||||||||||||||||||||||||
| } = usePaging(PAGE_SIZE_LARGE); | ||||||||||||||||||||||||||||||||||
| const { fqn: tableFqn } = useFqn(); | ||||||||||||||||||||||||||||||||||
| const [searchText, setSearchText] = useState(''); | ||||||||||||||||||||||||||||||||||
| // Pagination state for columns | ||||||||||||||||||||||||||||||||||
| const [tableColumns, setTableColumns] = useState<Column[]>([]); | ||||||||||||||||||||||||||||||||||
|
|
@@ -98,47 +92,23 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |||||||||||||||||||||||||||||||||
| currentVersionData.changeDescription as ChangeDescription | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Function to fetch paginated columns or search results | ||||||||||||||||||||||||||||||||||
| const fetchPaginatedColumns = useCallback( | ||||||||||||||||||||||||||||||||||
| async (page = 1, searchQuery?: string) => { | ||||||||||||||||||||||||||||||||||
| if (!tableFqn) { | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| setColumnsLoading(true); | ||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||
| const offset = (page - 1) * pageSize; | ||||||||||||||||||||||||||||||||||
| const allHistoricalColumns = useMemo( | ||||||||||||||||||||||||||||||||||
| () => pruneEmptyChildren(currentVersionData.columns) ?? [], | ||||||||||||||||||||||||||||||||||
| [currentVersionData.columns] | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Use search API if there's a search query, otherwise use regular pagination | ||||||||||||||||||||||||||||||||||
| const response = searchQuery | ||||||||||||||||||||||||||||||||||
| ? await searchTableColumnsByFQN(tableFqn, { | ||||||||||||||||||||||||||||||||||
| q: searchQuery, | ||||||||||||||||||||||||||||||||||
| limit: pageSize, | ||||||||||||||||||||||||||||||||||
| offset: offset, | ||||||||||||||||||||||||||||||||||
| fields: 'tags', | ||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||
| : await getTableColumnsByFQN(tableFqn, { | ||||||||||||||||||||||||||||||||||
| limit: pageSize, | ||||||||||||||||||||||||||||||||||
| offset: offset, | ||||||||||||||||||||||||||||||||||
| fields: 'tags', | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| const filteredHistoricalColumns = useMemo(() => { | ||||||||||||||||||||||||||||||||||
| if (!searchText) { | ||||||||||||||||||||||||||||||||||
| return allHistoricalColumns; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| const lower = searchText.toLowerCase(); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| setTableColumns(pruneEmptyChildren(response.data) || []); | ||||||||||||||||||||||||||||||||||
| handlePagingChange(response.paging); | ||||||||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||||||||
| // Set empty state if API fails | ||||||||||||||||||||||||||||||||||
| setTableColumns([]); | ||||||||||||||||||||||||||||||||||
| handlePagingChange({ | ||||||||||||||||||||||||||||||||||
| offset: 1, | ||||||||||||||||||||||||||||||||||
| limit: pageSize, | ||||||||||||||||||||||||||||||||||
| total: 0, | ||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||||||||||||||
| setColumnsLoading(false); | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| [tableFqn, pageSize] | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| return allHistoricalColumns.filter( | ||||||||||||||||||||||||||||||||||
| (col) => | ||||||||||||||||||||||||||||||||||
| col.name?.toLowerCase().includes(lower) || | ||||||||||||||||||||||||||||||||||
| col.description?.toLowerCase().includes(lower) | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
| }, [allHistoricalColumns, searchText]); | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+99
to
+105
|
||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleSearchAction = useCallback( | ||||||||||||||||||||||||||||||||||
| (searchValue: string) => { | ||||||||||||||||||||||||||||||||||
|
|
@@ -150,10 +120,9 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const handleColumnsPageChange = useCallback( | ||||||||||||||||||||||||||||||||||
| ({ currentPage }: PagingHandlerParams) => { | ||||||||||||||||||||||||||||||||||
| fetchPaginatedColumns(currentPage, searchText); | ||||||||||||||||||||||||||||||||||
| handlePageChange(currentPage); | ||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||
| [paging, fetchPaginatedColumns, searchText] | ||||||||||||||||||||||||||||||||||
| [handlePageChange] | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| const paginationProps = useMemo( | ||||||||||||||||||||||||||||||||||
|
|
@@ -355,20 +324,19 @@ const TableVersion: React.FC<TableVersionProp> = ({ | |||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| // Fetch columns when search changes | ||||||||||||||||||||||||||||||||||
| useEffect(() => { | ||||||||||||||||||||||||||||||||||
| if (tableFqn && !isVersionLoading) { | ||||||||||||||||||||||||||||||||||
| // Reset to first page when search changes | ||||||||||||||||||||||||||||||||||
| fetchPaginatedColumns(currentPage, searchText || undefined); | ||||||||||||||||||||||||||||||||||
| if (isVersionLoading) { | ||||||||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| }, [ | ||||||||||||||||||||||||||||||||||
| isVersionLoading, | ||||||||||||||||||||||||||||||||||
| tableFqn, | ||||||||||||||||||||||||||||||||||
| searchText, | ||||||||||||||||||||||||||||||||||
| fetchPaginatedColumns, | ||||||||||||||||||||||||||||||||||
| pageSize, | ||||||||||||||||||||||||||||||||||
| currentPage, | ||||||||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||||||||
| const offset = (currentPage - 1) * pageSize; | ||||||||||||||||||||||||||||||||||
| setTableColumns(filteredHistoricalColumns.slice(offset, offset + pageSize)); | ||||||||||||||||||||||||||||||||||
| handlePagingChange({ | ||||||||||||||||||||||||||||||||||
| offset, | ||||||||||||||||||||||||||||||||||
| limit: pageSize, | ||||||||||||||||||||||||||||||||||
| total: filteredHistoricalColumns.length, | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
| setTableColumns(filteredHistoricalColumns.slice(offset, offset + pageSize)); | |
| handlePagingChange({ | |
| offset, | |
| limit: pageSize, | |
| total: filteredHistoricalColumns.length, | |
| const total = filteredHistoricalColumns.length; | |
| const nextOffset = offset + pageSize; | |
| const previousOffset = Math.max(offset - pageSize, 0); | |
| setTableColumns(filteredHistoricalColumns.slice(offset, offset + pageSize)); | |
| handlePagingChange({ | |
| offset, | |
| limit: pageSize, | |
| total, | |
| before: offset > 0 ? String(previousOffset) : undefined, | |
| after: nextOffset < total ? String(nextOffset) : undefined, |
Copilot
AI
Apr 19, 2026
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.
columnsLoading is now driven entirely by synchronous local filtering/slicing, but it still starts as true and is set to false in an effect. This will render the schema table in a loading state briefly even when isVersionLoading is false. Consider removing columnsLoading state entirely (or initialize it to false and only use it when truly async work is happening).
Copilot
AI
Apr 19, 2026
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.
The useEffect dependency array omits handlePagingChange even though it’s used inside the effect. This is likely to trigger react-hooks/exhaustive-deps lint warnings and can capture a stale reference if the hook implementation changes. Add handlePagingChange to the dependency list (or refactor to avoid the effect).
| }, [isVersionLoading, filteredHistoricalColumns, currentPage, pageSize]); | |
| }, [ | |
| isVersionLoading, | |
| filteredHistoricalColumns, | |
| currentPage, | |
| pageSize, | |
| handlePagingChange, | |
| ]); |
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.
filteredHistoricalColumnsonly matches on top-levelnameanddescription, and it is not recursive. This changes search behavior vsVersionTable’ssearchInColumns(which searchesdisplayName,dataType, and children). Consider reusing the samesearchInColumnslogic (or an equivalent recursive filter) for the full historical column tree before slicing, so nested/typed matches aren’t dropped.