Merged
Conversation
It looks like `row_to_json(t.*)` makes Multicorn think we're requesting no
columns from the FDW (this could be related to our Multicorn changes, but it
doesn't happen with the LQFDW):
```sql
explain SELECT row_to_json(p.*) FROM sg_tmp_67cecbc993a0738c2f815e80169dafd3.some_table p LIMIT 10
Limit (cost=20.00..20.02 rows=10 width=32)
-> Foreign Scan on some_table p (cost=20.00..237.38 rows=94954 width=32)
Multicorn: Socrata query to data.cityofnewyork.us
Multicorn: Socrata dataset ID: 8wbx-tsch
Multicorn: Query:
Multicorn: Columns:
Multicorn: Order: :id
```
This query returns JSON objects full of NULLs.
Rewrite the preview query to first get the first 10 rows as a materialized CTE,
then use `row_to_json` on the result, which seems to fix the issue:
```sql
explain SELECT t.* FROM sg_tmp_67cecbc993a0738c2f815e80169dafd3.some_table t LIMIT 10
Limit (cost=20.00..33620.00 rows=10 width=3360)
-> Foreign Scan on some_table t (cost=20.00..319045440.00 rows=94954 width=3360)
Multicorn: Socrata query to data.cityofnewyork.us
Multicorn: Socrata dataset ID: 8wbx-tsch
Multicorn: Query:
Multicorn: Columns: `last_date_updated`,`license_type`,`last_time_updated`,`vehicle_license_number`,`wheelchair_accessible`,`vehicle_year`,`permit_license_number`,`order_date`,`certification_date`,`base_address`,`base_name`,`reason`,`hack_up_date`,`expiration_date`,`vehicle_vin_number`,`base_number`,`base_telephone_number`,`dmv_license_plate_number`,`website`,`active`,`base_type`,`veh`,`name`
Multicorn: Order: :id
explain with p as materialized
(SELECT * FROM sg_tmp_67cecbc993a0738c2f815e80169dafd3.some_table LIMIT 10)
select row_to_json(p.*) from p
CTE Scan on p (cost=33620.00..33620.22 rows=10 width=32)
CTE p
-> Limit (cost=20.00..33620.00 rows=10 width=3360)
-> Foreign Scan on some_table (cost=20.00..319045440.00 rows=94954 width=3360)
Multicorn: Socrata query to data.cityofnewyork.us
Multicorn: Socrata dataset ID: 8wbx-tsch
Multicorn: Query:
Multicorn: Columns: `last_date_updated`,`license_type`,`last_time_updated`,`vehicle_license_number`,`wheelchair_accessible`,`vehicle_year`,`permit_license_number`,`order_date`,`certification_date`,`base_address`,`base_name`,`reason`,`hack_up_date`,`expiration_date`,`vehicle_vin_number`,`base_number`,`base_telephone_number`,`dmv_license_plate_number`,`website`,`active`,`base_type`,`veh`,`name`
Multicorn: Order: :id
```
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
It looks like
row_to_json(t.*)makes Multicorn think we're requesting nocolumns from the FDW (this could be related to our Multicorn changes, but it
doesn't happen with the LQFDW):
This query returns JSON objects full of NULLs.
Rewrite the preview query to first get the first 10 rows as a materialized CTE,
then use
row_to_jsonon the result, which seems to fix the issue: