Spark SQL NOT operator and Null-aware predicate sub-queries cannot be used in nested conditions

Multi tool use
Multi tool use








up vote
1
down vote

favorite












The following Spark SQL query works fine:



((country IN (FROM medium_countries) ) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


and the following one works fine:



FALSE = ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


but when I add NOT operator, like:



NOT ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


it fails with the following error:



Exception in thread "main" org.apache.spark.sql.AnalysisException: Null-aware predicate sub-queries cannot be used in nested conditions: (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20));;
Filter (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20))
: :- SubqueryAlias `medium_countries`
: : +- Project [value#6 AS country#8]
: : +- LocalRelation [value#6]
: +- SubqueryAlias `big_countries`
: +- Project [value#1 AS country#3]
: +- LocalRelation [value#1]
+- SubqueryAlias `users`
+- Project [name#19, email#20, phone#21, country#22, monotonically_increasing_id() AS UniqueID#27L]
+- Project [_1#14 AS name#19, _2#15 AS email#20, _3#16 AS phone#21, _4#17 AS country#22]
+- LocalRelation [_1#14, _2#15, _3#16, _4#17]


Could you please explain why NOT is not working there?










share|improve this question



























    up vote
    1
    down vote

    favorite












    The following Spark SQL query works fine:



    ((country IN (FROM medium_countries) ) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


    and the following one works fine:



    FALSE = ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


    but when I add NOT operator, like:



    NOT ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


    it fails with the following error:



    Exception in thread "main" org.apache.spark.sql.AnalysisException: Null-aware predicate sub-queries cannot be used in nested conditions: (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20));;
    Filter (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20))
    : :- SubqueryAlias `medium_countries`
    : : +- Project [value#6 AS country#8]
    : : +- LocalRelation [value#6]
    : +- SubqueryAlias `big_countries`
    : +- Project [value#1 AS country#3]
    : +- LocalRelation [value#1]
    +- SubqueryAlias `users`
    +- Project [name#19, email#20, phone#21, country#22, monotonically_increasing_id() AS UniqueID#27L]
    +- Project [_1#14 AS name#19, _2#15 AS email#20, _3#16 AS phone#21, _4#17 AS country#22]
    +- LocalRelation [_1#14, _2#15, _3#16, _4#17]


    Could you please explain why NOT is not working there?










    share|improve this question

























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      The following Spark SQL query works fine:



      ((country IN (FROM medium_countries) ) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      and the following one works fine:



      FALSE = ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      but when I add NOT operator, like:



      NOT ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      it fails with the following error:



      Exception in thread "main" org.apache.spark.sql.AnalysisException: Null-aware predicate sub-queries cannot be used in nested conditions: (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20));;
      Filter (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20))
      : :- SubqueryAlias `medium_countries`
      : : +- Project [value#6 AS country#8]
      : : +- LocalRelation [value#6]
      : +- SubqueryAlias `big_countries`
      : +- Project [value#1 AS country#3]
      : +- LocalRelation [value#1]
      +- SubqueryAlias `users`
      +- Project [name#19, email#20, phone#21, country#22, monotonically_increasing_id() AS UniqueID#27L]
      +- Project [_1#14 AS name#19, _2#15 AS email#20, _3#16 AS phone#21, _4#17 AS country#22]
      +- LocalRelation [_1#14, _2#15, _3#16, _4#17]


      Could you please explain why NOT is not working there?










      share|improve this question















      The following Spark SQL query works fine:



      ((country IN (FROM medium_countries) ) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      and the following one works fine:



      FALSE = ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      but when I add NOT operator, like:



      NOT ((country IN (FROM medium_countries)) AND (country IN (FROM big_countries))) AND EMAIL IS NOT NULL


      it fails with the following error:



      Exception in thread "main" org.apache.spark.sql.AnalysisException: Null-aware predicate sub-queries cannot be used in nested conditions: (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20));;
      Filter (NOT (country#22 IN (list#99 ) && country#22 IN (list#100 )) && isnotnull(EMAIL#20))
      : :- SubqueryAlias `medium_countries`
      : : +- Project [value#6 AS country#8]
      : : +- LocalRelation [value#6]
      : +- SubqueryAlias `big_countries`
      : +- Project [value#1 AS country#3]
      : +- LocalRelation [value#1]
      +- SubqueryAlias `users`
      +- Project [name#19, email#20, phone#21, country#22, monotonically_increasing_id() AS UniqueID#27L]
      +- Project [_1#14 AS name#19, _2#15 AS email#20, _3#16 AS phone#21, _4#17 AS country#22]
      +- LocalRelation [_1#14, _2#15, _3#16, _4#17]


      Could you please explain why NOT is not working there?







      apache-spark apache-spark-sql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 10 at 18:21

























      asked Nov 10 at 17:15









      alexanoid

      6,8601175166




      6,8601175166



























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241439%2fspark-sql-not-operator-and-null-aware-predicate-sub-queries-cannot-be-used-in-ne%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53241439%2fspark-sql-not-operator-and-null-aware-predicate-sub-queries-cannot-be-used-in-ne%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          kc1oBnJ3uk j Mdfqlk ntBPxySfxo1IHeJCRtGTRA2 O0,W5xWTVoFv0tcmGu7H 11L
          b,ldlaf62wnyCT8opLn98kVunDy,MK7Mrp,FPXfI8AY8KjL VxWil5,hSR,zOKypByGuyd6Yv6wnY75GqAJVWIq3F

          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          Can't figure out why I get Error loading static resource from app.xaml

          How to fill missing numeric if any value in a subset is missing, all other columns with the same subset are missing