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

Fix mixed layer oracle, fix #32521 #34358

Closed

Conversation

SebastienPeillet
Copy link
Contributor

@SebastienPeillet SebastienPeillet commented Feb 7, 2020

Description

Fix #32521

When Qgis loads Oracle database, it lists a row per geometry type in a table (yes, by design it think it could'nt be authorized to have several geometry types in a table... but it's oracle).

In the issue example, for the same table, there is two entries. One for polygon and one for multipolygon. But when user loads the polygon layer, all polygon geometries (included multipolygon) are loaded and the reverse is also true for the multipolygon layer.

I fixed it by filtering simple and multi geometries in the oracle connection. Doing this, i had to fix some functions in the provider :

  • featuresCount function, to count only the wanted geometries,
  • addFeatures function because a simple geometry was not cast into multi geometry when the loaded layer was the multi geometry one (the new feature disappeared when user commits the changes)

EDIT : after seeing troubles by only filter single and multi geometry, I also filtered geometry types that were loaded together before (like LineString and CircularString), see my message below

I added testFilterSimpleMultiGeom test, but I also had to fix some tests in consequence.

Could be backported to 3.10.

CheckList

… the same table, fix addFeatures function to cast simple geom to multi geom when the loaded layer has multi geom type
@SebastienPeillet SebastienPeillet changed the title Fix mixed layer oracle Fix mixed layer oracle, fix #32521 Feb 7, 2020
@nyalldawson nyalldawson added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels Feb 22, 2020
@nyalldawson nyalldawson added this to the 3.14.0 milestone Feb 22, 2020
Copy link
Contributor

@troopa81 troopa81 left a comment

Choose a reason for hiding this comment

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

I think there is a problem because there is only one detected geometry when it could have several (multipolygon and polygon for instance)

EDIT: forget about this one, I miss the second qry.next and so the detectedType will be Unknown, so it works

src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
src/providers/oracle/qgsoracleprovider.cpp Outdated Show resolved Hide resolved
@tomass
Copy link
Contributor

tomass commented Mar 11, 2020

What about a use case where we do not care if it is a polygon or a multi-polygon? This PR would break it?

@stale
Copy link

stale bot commented Mar 26, 2020

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Mar 26, 2020
@stale
Copy link

stale bot commented Apr 2, 2020

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label May 26, 2020
@SebastienPeillet SebastienPeillet removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 13, 2020
@stale
Copy link

stale bot commented Jul 27, 2020

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Jul 27, 2020
@stale
Copy link

stale bot commented Aug 8, 2020

While we hate to see this happen, this PR has been automatically closed because it has not had any activity in the last 21 days. If this pull request should be reconsidered, please follow the guidelines in the previous comment and reopen this pull request. Or, if you have any further questions, just ask! We love to help, and if there's anything the QGIS project can do to help push this PR forward please let us know how we can assist.

@stale stale bot closed this Aug 8, 2020
@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Aug 11, 2020
@Meibes Meibes mentioned this pull request Aug 21, 2020
@stale
Copy link

stale bot commented Aug 29, 2020

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Aug 29, 2020
@stale stale bot removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 1, 2020
@stale
Copy link

stale bot commented Sep 20, 2020

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 20, 2020
@SebastienPeillet SebastienPeillet removed the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Sep 24, 2020
@rldhont
Copy link
Contributor

rldhont commented Sep 25, 2020

Conflict to resolve

case QgsWkbTypes::LineString:
case QgsWkbTypes::LineString25D:
case QgsWkbTypes::LineStringZ:
// LineString gtype ends with 2, sdo_interpretation must not be equal to 2 (CircularString) or 3 (Nurbs)
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 this filter will decrease performances, because it requests all interpretation from the table and then join on PK. It is worth trying on big dataset but I'm pretty sure this one should be better

SELECT "pk" FROM QGIS.LINE_DATA l
WHERE mod(l."GEOM"."SDO_GTYPE",100) = 2
AND (
    SELECT MAX(DECODE(MOD(ROWNUM, 3), 0, t.COLUMN_VALUE, NULL)) 
    FROM TABLE(l."GEOM"."SDO_ELEM_INFO") t
    ) not in (2,3);

We should also put this request in a QString and reuse it in all following filters with just parameter for sdo_gtype and in/not in 2,3/4

@troopa81
Copy link
Contributor

troopa81 commented Oct 5, 2020

@SebastienPeillet Modifications looks fine to me. Did you manage to make some test on big dataset to check if there is no performance issues

@SebastienPeillet
Copy link
Contributor Author

@troopa81 I tried this morning with a table that has 162k features.

Without our modification : 162k features (simple and multi polygon) loaded in ~32s

With our modification : 108k features (simple polygon) loaded in ~35s

@SebastienPeillet
Copy link
Contributor Author

@troopa81

I did some test in Oracle to avoid QGIS interferences.

There is two requests that are been changed. I limited result to 100k lines to get

First request :

SELECT count(*) FROM "QGIS"."MIX_SIMPLE_MULTI_POLYGON" "FEATUREREQUEST" WHERE ( mod("FEATUREREQUEST"."GEOM".sdo_gtype,100) = 3);

  COUNT(*)
----------
    108390

Elapsed: 00:00:00.13

and with changes :

SELECT count(*) FROM "QGIS"."MIX_SIMPLE_MULTI_POLYGON" "FEATUREREQUEST" WHERE ( mod("FEATUREREQUEST"."GEOM".sdo_gtype,100) = 3 AND (SELECT MAX(DECODE(MOD(ROWNUM, 3), 0, t.COLUMN_VALUE, NULL)) FROM TABLE("FEATUREREQUEST"."GEOM".SDO_ELEM_INFO) t) not in (2,4) OR GEOM IS NULL);

  COUNT(*)
----------
    108390

Elapsed: 00:00:00.67

Second request

The second request is more difficult to evaluate due to print output. On one hand I measure the request with the print, on the other I remove the print by setting SET AUTOTRACE TRACEONLY but I got the plan explanation instead...

With output print :

The original request :

SELECT "pk" FROM "QGIS"."MIX_SIMPLE_MULTI_POLYGON" "FEATUREREQUEST" WHERE ( mod("FEATUREREQUEST"."GEOM".sdo_gtype,100) = 3 );

with changes :

SELECT "pk" FROM "QGIS"."MIX_SIMPLE_MULTI_POLYGON" "FEATUREREQUEST" WHERE ( mod("FEATUREREQUEST"."GEOM".sdo_gtype,100) = 3 AND (SELECT MAX(DECODE(MOD(ROWNUM, 3), 0, t.COLUMN_VALUE, NULL)) FROM TABLE("FEATUREREQUEST"."GEOM".SDO_ELEM_INFO) t) not in (2,4) OR GEOM IS NULL);

for both, execution time is between 3.75s and 4.22s, depends on print surely.

Without print but with explain

For original request the execution time is between 0.78s and 1.02s

For modified request the execution time is between 1.42s and 1.56s

@stale
Copy link

stale bot commented Nov 7, 2020

The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check

  • that all unit tests are passing

  • that all comments by reviewers have been addressed

  • that there is enough information for reviewers, in particular

    • link to any issues which this pull request fixes

    • add a description of workflows which this pull request fixes

    • add screenshots if applicable

  • that you have written unit tests where possible
    In case you should have any uncertainty, please leave a comment and we will be happy to help you proceed with this pull request.
    If there is no further activity on this pull request, it will be closed in a week.

@stale stale bot added the stale Uh oh! Seems this work is abandoned, and the PR is about to close. label Nov 7, 2020
@nyalldawson
Copy link
Collaborator

Closing manually because stale-bot seems to have gone on holiday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers stale Uh oh! Seems this work is abandoned, and the PR is about to close.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Oracle : tables are listed once for Polygons and once for MultiPolygons but both show all geometries
5 participants