'How to change value for parameter in BigQuery datatable with SQL
Situation
I have a BigQuery datatable (004a-TWtweets-02) of Twitter posts (tweets).
For a given tweet_id parameter, I am trying to change the score value from .3 to .2, which will then change a sentiment2 value from positive to neutral.
Attempted solution
I'm using this BQ SQL:
UPDATE `pp-004a.004a02.004a-TWtweets-02` SET score=2 WHERE tweet_id=1525524602327379969;
Results
That worked for the score parameter, as when I search for that tweet:
SELECT * FROM `pp-004a.004a02.004a-TWtweets-02` WHERE tweet_id=1525524602327379969
I found the new score value to be '2'.
Error
However, when I try to update the calculation for the sentiment2 parameter across the entire datatable, per below …
UPDATE
'pp-004a.004a02.004a-TWtweets-02'
SET
sentiment2 =
CASE
WHEN score<=-0.3 THEN 'Negative'
WHEN score>=0.3 THEN 'Positive'
ELSE
'Neutral'
END
WHERE
TRUE
… the same tweet_id value 1525524602327379969 still has a sentiment2 value of positive, when it should be neutral based on the new score being below the positive threshold of 3.
Is there something I'm overlooking here?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
