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

Add ToString and Print method for JoinRelationSetManager and Fix JoinNode Print #9040

Merged
merged 2 commits into from
Nov 8, 2023

Conversation

Light-City
Copy link
Contributor

@Light-City Light-City commented Sep 22, 2023

1.When we want to debug JoinRelationSetManager., we need to add the ToString and Print method.

for example: explain SELECT COUNT(*) FROM t1, t2, t3, t4 WHERE t1.c1 = t2.c1 AND t2.c2 = t3.c2 AND t3.c3 = t4.c3 ;

set_manager.Print();

will output:

child: 0
  relation: [0]
  child: 1
      relation: [0, 1]
child: 1
  relation: [1]
  child: 2
      relation: [1, 2]
child: 3
  relation: [3]
child: 2
  relation: [2]
  child: 3
      relation: [2, 3]

2.Change PrintJoinNode to Print and implement it.

Copy link
Contributor

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

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

Thank you for the PR! This should indeed come in handy when debugging. Just have some notes.

The RelationSetManager keeps track of already created relations. The way these references are stored isn't very intuitive, and muddies the logic as to what the RelationSetManager is actually doing, but it's an efficient implementation if joins have a very large number of relations. Currently it is a type of tree structure where every node has a reference to the relation set.

That being said, can we instead just iterate over all the JoinRelationSets/Values in the tree, add each JoinRelationSet to a "to_print" variable and print all the join relations created so far? This way we don't have to do this indenting stuff with "child" nodes. Relations technically don't even have children.

For your example, I think a better output would look like this.

RelationSets created:
[0]
[0,1]
[1]
[1,2]
[3]
[2]
[2,3]

@Tmonster Tmonster self-requested a review September 22, 2023 09:14
@github-actions github-actions bot marked this pull request as draft September 22, 2023 10:24
@Light-City Light-City marked this pull request as ready for review September 22, 2023 10:34
@github-actions github-actions bot marked this pull request as draft September 22, 2023 11:59
@Light-City Light-City marked this pull request as ready for review September 22, 2023 13:00
@github-actions github-actions bot marked this pull request as draft September 24, 2023 04:13
@Light-City
Copy link
Contributor Author

Light-City commented Sep 24, 2023

Thank you for the PR! This should indeed come in handy when debugging. Just have some notes.

The RelationSetManager keeps track of already created relations. The way these references are stored isn't very intuitive, and muddies the logic as to what the RelationSetManager is actually doing, but it's an efficient implementation if joins have a very large number of relations. Currently it is a type of tree structure where every node has a reference to the relation set.

That being said, can we instead just iterate over all the JoinRelationSets/Values in the tree, add each JoinRelationSet to a "to_print" variable and print all the join relations created so far? This way we don't have to do this indenting stuff with "child" nodes. Relations technically don't even have children.

For your example, I think a better output would look like this.

RelationSets created:
[0]
[0,1]
[1]
[1,2]
[3]
[2]
[2,3]

Indeed, I very much agree with your point of view. I have made modifications to the code.

@Light-City Light-City marked this pull request as ready for review September 24, 2023 04:14
When we want to debug JoinRelationSetManager., we need to add the ToString and Print method.
@github-actions github-actions bot marked this pull request as draft September 24, 2023 04:44
@Light-City Light-City marked this pull request as ready for review September 24, 2023 04:44
@github-actions github-actions bot marked this pull request as draft September 24, 2023 04:44
@Light-City Light-City marked this pull request as ready for review September 24, 2023 08:38
@github-actions github-actions bot marked this pull request as draft September 24, 2023 08:48
@Light-City
Copy link
Contributor Author

In addition, I found that PrintJoinNode of JoinNode is not defined. Here I modify it to Print and implement it.

@Light-City Light-City marked this pull request as ready for review September 24, 2023 08:49
@Light-City
Copy link
Contributor Author

In addition, I found that PrintJoinNode of JoinNode is not defined. Here I modify it to Print and implement it.

related issue is #9067

@Light-City Light-City changed the title Add ToString and Print method for JoinRelationSetManager. Add ToString and Print method for JoinRelationSetManager and Fix JoinNode Print Sep 24, 2023
Copy link
Contributor

@Tmonster Tmonster left a comment

Choose a reason for hiding this comment

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

Thanks! Pr looks good to me

@Light-City
Copy link
Contributor Author

@Tmonster @Mytherin

Can this PR be merged? Are there any modifications needed?

@Mytherin Mytherin changed the base branch from main to feature November 8, 2023 12:51
@Mytherin Mytherin merged commit be47ec4 into duckdb:feature Nov 8, 2023
48 of 49 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Nov 8, 2023

Thanks

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 11, 2023
Merge pull request duckdb/duckdb#9164 from Mause/feature/jdbc-uuid-param
Merge pull request duckdb/duckdb#9185 from pdet/adbc_07
Merge pull request duckdb/duckdb#9126 from Maxxen/parquet-kv-metadata
Merge pull request duckdb/duckdb#9123 from lnkuiper/parquet_schema
Merge pull request duckdb/duckdb#9086 from lnkuiper/json_inconsistent_structure
Merge pull request duckdb/duckdb#8977 from Tishj/python_readcsv_multi_v2
Merge pull request duckdb/duckdb#9279 from hawkfish/nsdate-cast
Merge pull request duckdb/duckdb#8851 from taniabogatsch/binary_lambdas
Merge pull request duckdb/duckdb#8983 from Maxxen/types/fixedsizelist
Merge pull request duckdb/duckdb#9318 from Maxxen/fix-unused
Merge pull request duckdb/duckdb#9220 from hawkfish/exclude
Merge pull request duckdb/duckdb#9230 from Maxxen/json-plan-serialization
Merge pull request duckdb/duckdb#9011 from Tmonster/add_create_statement_support_to_fuzzer
Merge pull request duckdb/duckdb#9400 from Maxxen/array-fixes
Merge pull request duckdb/duckdb#8741 from Tishj/python_import_cache_upgrade
Merge fixes
Merge pull request duckdb/duckdb#9395 from taniabogatsch/lambda-performance
Merge pull request duckdb/duckdb#9427 from Tishj/python_table_support_replacement_scan
Merge pull request duckdb/duckdb#9516 from carlopi/fixformat
Merge pull request duckdb/duckdb#9485 from Maxxen/fix-parquet-serialization
Merge pull request duckdb/duckdb#9388 from chrisiou/issue217
Merge pull request duckdb/duckdb#9565 from Maxxen/fix-array-vector-sizes
Merge pull request duckdb/duckdb#9583 from carlopi/feature
Merge pull request duckdb/duckdb#8907 from cryoEncryp/new-list-functions
Merge pull request duckdb/duckdb#8642 from Virgiel/capi-streaming-arrow
Merge pull request duckdb/duckdb#8658 from Tishj/pytype_optional
Merge pull request duckdb/duckdb#9040 from Light-City/feature/set_mg
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.

None yet

3 participants