null

Avoid nested aggregate error using coalesce()

浪子不回头ぞ 提交于 2020-07-03 13:41:27
问题 I currently have a query using coalesce that worked in SQL server,however, it is not working in Amazon Redshift. Is there a way I can more appropriately write this to use in Redshift: coalesce(sum(Score)/nullif(sum(ScorePrem),0),0) as percent 回答1: Consider running the aggregate query as a subquery or CTE, then handle transformation or secondary calculations in an outer main query. WITH agg AS ( SELECT calendar_month_id ,day_of_month ,month_name ,DaysRemaining ,RPTBRANCH ,0 AS TotalGrp ,SUM

Why FreeAndNil implementation doing Nil before Free?

痞子三分冷 提交于 2020-06-29 06:41:46
问题 If you will look at the code of FreeAndNil procedure you will see: procedure FreeAndNil(var Obj); var Temp: TObject; begin Temp := TObject(Obj); Pointer(Obj) := nil; Temp.Free; end; What is the reason they assigning Nil to an object reference and only after this destroying it? Why not vice-versa? 回答1: I can think of two reasons for doing it this way round, neither of which seems at all compelling. Reason 1: to guarantee that the reference is set to nil in case an exception is raised The

In C# 8, how do I detect impossible null checks?

三世轮回 提交于 2020-06-27 08:45:52
问题 I've started using nullable reference types in C# 8. So far, I'm loving the improvement except for one small thing. I'm migrating an old code base, and it's filled with a lot of redundant or unreachable code, something like: void Blah(SomeClass a) { if (a == null) { // this should be unreachable, since a is not nullable } } Unfortunately, I don't see any warning settings that can flag this code for me! Was this an oversight by Microsoft, or am I missing something? I also use ReSharper, but

How to detect null values in a vector

青春壹個敷衍的年華 提交于 2020-06-27 07:10:11
问题 Whats the best way to detect null values in a vector? If I have the vector below and want to know that the 4th position is null how would I do that? vx <- c(1, 2, 3, NULL, 5) is.null() returns only FALSE : is.null(vx) # [1] FALSE and I'd like to get: FALSE FALSE FALSE TRUE FALSE 回答1: As mentioned in the comments, NULL will not appear in length(vx) . It is a special object in R for undefined values. From CRAN documentation: NULL represents the null object in R: it is a reserved word. NULL is

Why FreeAndNil implementation doing Nil before Free?

笑着哭i 提交于 2020-06-27 07:00:15
问题 If you will look at the code of FreeAndNil procedure you will see: procedure FreeAndNil(var Obj); var Temp: TObject; begin Temp := TObject(Obj); Pointer(Obj) := nil; Temp.Free; end; What is the reason they assigning Nil to an object reference and only after this destroying it? Why not vice-versa? 回答1: I can think of two reasons for doing it this way round, neither of which seems at all compelling. Reason 1: to guarantee that the reference is set to nil in case an exception is raised The

NOT IN implementation of Presto v.s Spark SQL

我们两清 提交于 2020-06-25 10:51:33
问题 I got a very simple query which shows significant performance difference when running on Spark SQL and Presto (3 hrs v.s 3 mins) in the same hardware. SELECT field FROM test1 WHERE field NOT IN (SELECT field FROM test2) After some research of the query plan, I found out the reason is how Spark SQL deals with NOT IN predicate subquery. To correctly handle the NULL of NOT IN, Spark SQL translate the NOT IN predicate as Left AntiJoin( (test1=test2) OR isNULL(test1=test2)) . Spark SQL introduces

GetRef's memory consumption (garbage collection) changed with KB4525236

荒凉一梦 提交于 2020-06-24 22:01:10
问题 We experience out-of-memory issues after installing KB4525236 on our Windows 2016 Servers/Windows 10 Clients. This security fix seems to have changed the moment when memory is garbage collected when calling a function through GetRef . Pré KB4525236 Each instance created in a function called through GetRef got garbage collected as soon as the instance variable was set to nothing Post KB4525236 Each instance created in a function called through GetRef remains in memory and is garbage collected

What is a good substitute for DSPF with physical files that contain nulls?

泄露秘密 提交于 2020-06-18 16:49:29
问题 I have found that the command DSPF (Display Physical file) does not correctly display records that contain a null. If I define a physical file in DDS with the ALWNULL keyword on a field, then fill the file with data, DSPF will correctly display the data for records without nulls, but all records that contain at least one null will display only blanks in both the null and the non-null fields. This can be misleading. For example in the screenshot below, the seemingly blank records have data in

What is a good substitute for DSPF with physical files that contain nulls?

戏子无情 提交于 2020-06-18 16:49:06
问题 I have found that the command DSPF (Display Physical file) does not correctly display records that contain a null. If I define a physical file in DDS with the ALWNULL keyword on a field, then fill the file with data, DSPF will correctly display the data for records without nulls, but all records that contain at least one null will display only blanks in both the null and the non-null fields. This can be misleading. For example in the screenshot below, the seemingly blank records have data in

Unexpected BLOB results with MySQL testing NULL variable with IFNULL, COALESCE

耗尽温柔 提交于 2020-06-17 09:48:06
问题 In trying to test whether a variable has been defined, I discovered that the IF, IFNULL, and COALESCE statements return simply BLOB rather than the value I expected when (a) the variable has not been defined or (b) it has been explicitly set to NULL before being assigned a value in the session. I've verified this in MySQL versions 5.7 and 8.0. SELECT IF(@p IS NULL, 'is null', 'not null'); # 'is null' SELECT IF(@p IS NULL, 'is null', @p); # BLOB SELECT IFNULL(@p, 'is null'); # BLOB SELECT