locked
COMException on UnionAggregate RRS feed

  • Question

  • Hello,

    I've run into a weird issue with geography::UnionAggregate.  I'm having a problem where it throws a COMException with an HRESULT of E_FAIL.  I've only noticed it after running Reduce on geography, though I haven't been able to run queries with the original data to the end.  (I currently have one that's been running for 15 hours, with no sign of stopping.)

    Does anyone have any idea how I'd even start debugging something like this?

    This is the text of the error:

    Msg 6522, Level 16, State 1, Line 1
    A .NET Framework error occurred during execution of user-defined routine or aggregate "GeographyUnionAggregate": 
    System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.
    System.Runtime.InteropServices.COMException: 
       at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
       at Microsoft.SqlServer.Types.GLNativeMethods.ThrowExceptionForHr(GL_HResult errorCode)
       at Microsoft.SqlServer.Types.GLNativeMethods.GeodeticCombine(CombineMode combineMode, GeoData g1, GeoData g2, Double eccentricity)
       at Microsoft.SqlServer.Types.GeographyUnionAggregate.Terminate()
    .

    And this query produces it (with the reduced dataset):

    select
        *
    from
        tblGeography
        cross apply
        (
            select
                geography::UnionAggregate(ZC_Geography) as NewGeom
            from
                tblGeographyDetail
                join tblZipCode on ZC_Zip_Code like GD_Zip_Code
            where
                GD_GEO_ID=GEO_ID
        ) a
    where
        GEO_ID=2



    Thursday, July 6, 2017 1:52 PM