Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
7
votes
3 answers

Check if arraytype column contains null

I have a dataframe with a column of arraytype that can contain integer values. If no values it will contain only one and it will be the null value Important: note the column will not be null but an array with a single value; null > val df: DataFrame…
7
votes
5 answers

JS Last index of a non-null element in an array

I have an array with defined and null values inside, like so : var arr = [ {...}, null, null, {...}, null ]; Is there any way for me to get the index of the last non-null element from this array? And I mean without having to loop through…
Zenoo
  • 12,670
  • 4
  • 45
  • 69
7
votes
3 answers

C# value type initialized with null

In C# 3.0 you can assign null to int? type (in CLR int? is a struct): int? a = null; but when you define a custom struct: struct MyStruct { } there's an error during the compilation of this code: MyStruct a = null; The error is as…
mgamer
  • 13,580
  • 25
  • 87
  • 145
7
votes
3 answers

MySQL Select with LIKE and WHERE

I have a table of biographical data, and I need to do a query that selects people who have the word "died" in their bio and whose death date is NULL. This doesn't work: SELECT * FROM people WHERE bio LIKE '%died%' AND death_date IS NULL That…
kirkaracha
  • 742
  • 2
  • 14
  • 23
7
votes
2 answers

Selenium + PHPUnit: sessionId should not be null; has this session been started yet?

I'm running Selenium RC with PHP. I run a simple login test, that completes successfully, but just before closing the browser, I get the following error: 23:50:09.969 INFO - Command request: testComplete[, ] on session …
Shimix
  • 93
  • 2
  • 7
7
votes
6 answers

Count the number of non-null values in a Spark DataFrame

I have a data frame with some columns, and before doing analysis, I'd like to understand how complete the data frame is. So I want to filter the data frame and count for each column the number of non-null values, possibly returning a dataframe…
user299791
  • 2,021
  • 3
  • 31
  • 57
7
votes
2 answers

Postgresql and comparing to an empty field

It seems that in PostgreSQL, empty_field != 1 (or some other value) is FALSE. If this is true, can somebody tell me how to compare with empty fields? I have following query, which translates to "select all posts in users group for which one hasn't…
spacemonkey
  • 19,664
  • 14
  • 42
  • 62
7
votes
3 answers

Is SQL unknown identical to NULL?

I'm confused what does UNKNOWN means in SQL in 3 valued logic. Does it mean NULL actually? Is it true that NULL and UNKNOWN can be interchangeable in all boolean contexts?
Michael Tsang
  • 678
  • 5
  • 16
7
votes
2 answers

java.lang.ClassCastException with null message and cause

I work on a project using Java 8 We have a negative test similar to this: public Integer g(Object data) { try { Double d = (Double)data; } catch(ClassCastException ex) { if( ex.getMessage() == null ) { …
E. Levy
  • 73
  • 1
  • 1
  • 6
7
votes
3 answers

Kotlin Set to Null If Not Null

Is there an idiom in Kotlin for setting a variable to null if it is not already null? Something more semantically pleasing than: var test: String? = null if(test != null) test = null
Eliezer
  • 7,209
  • 12
  • 56
  • 103
7
votes
5 answers

Spark scala remove columns containing only null values

Is there a way to remove the columns of a spark dataFrame that contain only null values ? (I am using scala and Spark 1.6.2) At the moment I am doing this: var validCols: List[String] = List() for (col <- df_filtered.columns){ val count =…
maxk
  • 161
  • 2
  • 7
7
votes
5 answers

How to avoid multiple if null checks

Possible Duplicates: Deep Null checking, is there a better way? C# elegant way to check if a property's property is null i have to do a lookup in a deep object model like this: p.OrganisationalUnit.Parent.Head.CurrentAllocation.Person; is…
leora
  • 188,729
  • 360
  • 878
  • 1,366
7
votes
1 answer

Replace null string with null value

I have a table that has a string value of 'null' that I wish to replace with an actual NULL value. However if I try to do the following in my select Select Replace(Mark,'null',NULL) from tblname It replaces all rows and not just the rows with the…
BlueBird
  • 1,406
  • 4
  • 24
  • 35
7
votes
3 answers

mysql error 'NULL' at line 1

I got this error when tried to execute this: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NULL' at line 1 Can't seems to find what is the…
Wahsei
  • 289
  • 2
  • 6
  • 16
7
votes
2 answers

to_tsvector is empty if any column has no data in PostgreSQL Full Text Search

I am trying to implement a Postgre SQL Full Text Search but I am running into a problem with the entire document returning empty if any of the columns set with to_tsvector are empty. I have a table that looks like the following: id | title | …
knsheely
  • 543
  • 5
  • 13