Add New column with constant value in SuperSet - apache-superset

I'm looking to add a column with a default value in superset.
All rows will be filled with the value "ABC".
Are there anyone can help me?

Just use single '.
SELECT *,
'ABC' as "new_column"
FROM BDD

Related

PySpark dataframe remove white-spaces from a column of the string

Here in this pic, column Values contains some string values where the spaces are there in between, hence I am unable to convert this column to an Integer type.
If you can help me remove this white space from these string values, I can then cast them easily.
I have trieddf_cause_death_france.select(regexp_replace(col("Value")," ",""))
It does works but it removes all other columns from my spark dataframe.
please ignore this question. I am able to solve it.
In case you want to know my solution, here it is.
df_cause_death_france.withColumn('VALUE', regexp_replace('Value', ' ','')).show()
output =
https://i.stack.imgur.com/1bljf.png

Select cell in Google Sheets where cell begins with specific character

I have a range of cells B5:I5, and I need to select the cell which starts with 'R'. Tried with query, but can't the result.
Could somebody help please?
try:
=FILTER(B5:I5; REGEXMATCH(B5:I5; "^R.+"))
or:
=TRANSPOSE(QUERY(FLATTEN(B5:I5); "where Col1 starts with 'R'"))
or:
=TRANSPOSE(QUERY(FLATTEN(B5:I5); "where Col1 matches '^R'"))

Postgres regexp_replace query usage

We have a column with a particular prefix value followed by dynamic digits, for example,
AAAA0000
AAAA0001
AAAA0002
AAAA0003
...
...
Now we want to update the prefix value from AAAA to BBBB in all the rows it exists. I have tried using regexp_replace, replace and also other possible function but without success.
Could you please help me to do this?
update table_name set the_column = 'BBBB'||substr(the_column, 6,13) where the_column like 'AAAA%';
Where as, 6 is the starting position of the digits and 13 is the ending position of the string..
So the value 'BBBB' will get updated till the position 5 and then the concatenation of sub string as extracted above.
I don't see the need for regex here:
update the_table
set the_column = 'BBBB'||substr(the_column, 5)
where the_column like 'AAAA%';
Here's how you use regexp_replace here:
update the_table
set the_column = regexp_replace(the_column, '^AAAA', 'BBBB');

Regular Expression in ms excel

How can I use regular expression in excel ?
In above image I have column A and B. I have some values in column A. Here I need to move data after = in column B. For e.g. here in 1st row I have SELECT=Hello World. Here I want to remove = sign and move Hello world in column B. How can I do such thing?
Stackoverflow has many posts about adding regular expressions to Excel using VBA. For your particular example, you would need VBA to actually move a substring from one cell to another.
If you simply want to copy the substring, you can do so easily using the MID function:
=IFERROR(MID(A1,FIND("=",A1)+1,999),A1)
I used 999 to ensure that enough characters were grabbed.
IFERROR returns the cell as-is if an equals sign is not found.
To return the portion of string before the equals sign, do this:
=LEFT(A1,FIND("=",A1&"=")-1)
In this case, I appended the equals sign to A1, so FIND won't return an error if not found.
You can use the Text to Column functionality of MS-Excel giving '=' as delimiter.
Refer to this link:
Chop text in column to 60 charactersblocks
You can simply use Text to Column feature of excel for this:
Follow the below steps :
1) Select Column A.
2) Goto Data Tab in Menu Bar.
3) Click Text to Column icon.
4) Choose Delimited option and do Next and then check the Other options in delimiter and enter '=' in the entry box.
5) Just click finish.
Here are URL for Text to Column : http://www.excel-easy.com/examples/text-to-columns.html

regular expression clob field

I have a question related to an regular expression in oracle 10.
Assuming I have a value like 123456;12345;454545 stored in a clob field, is there a way via an regular expression to only filter on the second pattern (12345) knowing that the value can be more then 5 digits but always occurs after the first semicolon and always has a trailing semicolon at the end?
Thanks a lot for your support in that matter,
Have a nice day,
This query should give you your desired output.
SELECT REGEXP_REPLACE(REGEXP_SUBSTR('123456;12345;454545;45634',';[0-9]+;'),';')
FROM dual;
You can get filter any pattern using this query just change 2 to any value, but it should be less than or equal to the number of elements in the string
with tab(value) as
(select '123456;12345;454545' from dual)
select regexp_substr(value, '[^;]+', 1, 2) from tab;
easily by one call:
select regexp_replace('123456;12345;454545','^[0-9]+;([0-9]+);.*$','\1')
from dual;
perhaps, regexp expression can be modified in a way of more good-looking or your business logic, but the idea, I think, is clear.
select regexp_replace(regexp_substr(Col_name,';\d+;'),';','') from your_table;