Skip to content

Conversation

@lowka
Copy link
Contributor

@lowka lowka commented Sep 18, 2023

Makes system views accessible to planner via calcite's Table class.

  • Introduces IgniteDataSource interface that represents both Tables and System Views.
  • Extracts common fields from IgniteTable to IgniteDataSource.

https://issues.apache.org/jira/browse/IGNITE-20020


Thank you for submitting the pull request.

To streamline the review process of the patch and ensure better code quality
we ask both an author and a reviewer to verify the following:

The Review Checklist

  • Formal criteria: TC status, codestyle, mandatory documentation. Also make sure to complete the following:
    - There is a single JIRA ticket related to the pull request.
    - The web-link to the pull request is attached to the JIRA ticket.
    - The JIRA ticket has the Patch Available state.
    - The description of the JIRA ticket explains WHAT was made, WHY and HOW.
    - The pull request title is treated as the final commit message. The following pattern must be used: IGNITE-XXXX Change summary where XXXX - number of JIRA issue.
  • Design: new code conforms with the design principles of the components it is added to.
  • Patch quality: patch cannot be split into smaller pieces, its size must be reasonable.
  • Code quality: code is clean and readable, necessary developer documentation is added if needed.
  • Tests code quality: test set covers positive/negative scenarios, happy/edge cases. Tests are effective in terms of execution time and resources.

Notes

@lowka lowka force-pushed the IGNITE-20020 branch 8 times, most recently from 9267a27 to 6dcc608 Compare September 19, 2023 19:28
@lowka lowka marked this pull request as ready for review September 20, 2023 05:38
*/
public class IgniteSystemViewScan extends ProjectableFilterableTableScan implements SourceAwareIgniteRel {

private final long sourceId;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please add a javadoc with an explanation what is it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed an issue to document SourceIgniteRel - https://issues.apache.org/jira/browse/IGNITE-20461

if (srcIdObj != null) {
sourceId = ((Number) srcIdObj).longValue();
} else {
sourceId = -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so many times used -1, let's introduce constant for it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be we can create an issue to fix this for all scan operations?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it good idea

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String viewName = systemViewDescriptor.name();
TableDescriptor descriptor = createTableDescriptorForSystemView(systemViewDescriptor);

IgniteSystemView schemaTable = new IgniteSystemViewImpl(viewName, viewId, version, descriptor, Statistics.UNKNOWN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is seems we could have special statistics realization for system views. At least we know distribution

Copy link
Contributor Author

@lowka lowka Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there is no statistics for rows for system views, because the API asks a user to provide it a function that returns data (see SystemView's dataProvider property).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but statistics it not only about concrete rows, it also knowns about data structure and distribution, both of them don't depends on dataprovider

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Fixed.

@lowka lowka requested a review from ygerzhedovich September 21, 2023 12:28

@Override
public FragmentMapping visit(IgniteSystemViewScan rel) {
throw new UnsupportedOperationException();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
throw new UnsupportedOperationException();
throw new UnsupportedOperationException("System view scan is not implemented");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

private static final AtomicInteger SYSTEM_VIEW_ID = new AtomicInteger();

@Test
public void testReadAllColumns() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertPlan("INSERT into SYS_PROPS(key, VAL) VALUES('', '')"
throws confused exception, seems all cases with VIEWS mutations need to be covered.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CREATE INDEX idx on SYS_PROPS
the same i suppose

Copy link
Contributor Author

@lowka lowka Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no facilities to add such tests - there is no means to write DDL tests for the planner.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertPlan("INSERT into SYS_PROPS(key, VAL) VALUES('', '')"

Fixed.

assert dataSource != null;

if (dataSource instanceof IgniteSystemView) {
throw newValidationError(identifier, IgniteResource.INSTANCE.systemViewIsNotModifiable(identifier.toString()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that SysView mutation error need to be raised not from getIgniteTable call, wdyt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to getTableForModification.

Fix INSERT, Rename get*Table methods.
Add error message.
@lowka lowka requested a review from zstan September 26, 2023 12:10
@zstan zstan merged commit 11703c3 into apache:main Sep 27, 2023
@zstan zstan deleted the IGNITE-20020 branch September 27, 2023 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants