Why would MakeQueryLayer_management return an empty object?

553
3
Jump to solution
09-09-2021 05:40 PM
Labels (2)
JesseTemplin2
New Contributor III

Hello,

I am using MakeQueryLayer_management to read from a Postgres database and populate a table in a file geodatabase.

I have two sde connections for the postgres database. Let's call them user_A.sde and user_B.sde. Each corresponds to a user on the postgres database with the same permissions. Both users can query the table in a third party tool. And both connections can view the table in ArcGIS Pro. And both connections can drag and drop the table into an ArcGIS Pro project.

The problem is when I call MakeQueryLayer_management in ArcPy, one of the users returns the table as expected and the other returns an empty result object. The only change I am making is the path to the sde connection file.

Why would MakeQueryLayer_management return an empty object?

Thanks

0 Kudos
1 Solution

Accepted Solutions
JesseTemplin2
New Contributor III

This appears to be a bug, not limited to MakeQueryLayer

BUG-000139927 

View solution in original post

3 Replies
LongDinh
Occasional Contributor II

Hi @JesseTemplin2 ,

According to the usage notes in the tool documentation

If the result of the SQL query does not return any rows, the output query layer will be empty, only containing the schema of the columns returned by the query. In this case, if the columns returned contain a spatial column, the tool will use the following defaults to create the query layer:

  • Geometry type—POINT
  • SRID—1
  • Spatial Reference—NAD1983

Then you need to determine whether any of these values should be changed before executing the tool.

So perhaps the Query is not correct? Can you run the tool in ArcGIS Pro and copy the snippet to your python script and see if it works?

0 Kudos
JesseTemplin2
New Contributor III

Same deal if I run the tool in ArcGIS Pro. The query is a simple select * from table. One sde connection creates a table and the other doesn't.

0 Kudos
JesseTemplin2
New Contributor III

This appears to be a bug, not limited to MakeQueryLayer

BUG-000139927