Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-4926

.NET: Join fails in LINQ when subquery is using Select clause

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 2.1
    • platforms

    Description

      Using Join with subquery works when subquery does not contain Select clause:

      var persons = GetPersonCache().AsCacheQueryable().Where(x => x.Key >= 0);
      var orgs = GetOrgCache().AsCacheQueryable().Where(x => x.Key > 10);
      var res = persons.Join(orgs,
                      p => p.Value.OrganizationId,
                      o => o.Value.Id, (p, o) => p)
                      .Where(x => x.Key >= 0)
                      .ToList();
      

      And fails when subquery is using Select:

      var res = persons
          .Join(
              orgs.Where(orgEntry => orgEntry.Value.Name == "Org_1")
                  .Select(orgEntry => orgEntry.Key),
              e => e.Value.OrganizationId,
              i => i,
              (e, i) => e)
          .ToList();
      

      Exception:

      Failed to parse SQL query: select _T0._key, _T0._val from "".Person as _T0 inner join (select _T1._key from "".Organization as _T1 where (_T1._key > ?) and (_T1.Name = ?) ) as _T2 on (_T2._key, _T2._val = _T0.OrganizationId) where (_T0._key >= ?)
      Caused by: org.h2.jdbc.JdbcSQLException: Column "_T2._VAL" not found;
      

      This can be reproduced in CacheLinqTest.TestSubqueryJoin by adding next:

      var foo = persons
          .Join(
              orgs.Where(orgEntry => orgEntry.Value.Name == "Org_1")
                  .Select(orgEntry => orgEntry.Key),
              e => e.Value.OrganizationId,
              i => i,
              (e, i) => e)
          .ToArray();
      

      or

      var foo = orgs
          .Where(orgEntry => orgEntry.Value.Name == "Org_1")
          .Select(orgEntry => orgEntry.Key);
      var bar = persons
          .Join(foo, e => e.Value.OrganizationId, i => i, (e, i) => e)
          .ToArray();
      

      Attachments

        Issue Links

          Activity

            People

              gurustron Sergey Stronchinskiy
              gurustron Sergey Stronchinskiy
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: