Skip to main content
Taries
Silver ⭐️
Jan 31, 2024 5:22 AM UTC
Solved

Hbase filter query using pyspark

I am trying to pull the records from the Hbase based on the row key in pyspark using the following details

 

pyspark.JPG

 

but the records which is returning showing all the records (i,e without filter), can you please help me to resolving the issue

 

RangaReddy
Gold ⭐️
Feb 4, 2024 3:46 PM UTC

Hi @Taries 

I hope you are doing good. Do you need any further help on this issue. If above solutions is helped in your case please accept the Solution. It will help for others. 

5 replies

VidyaSargur
Community Manager
Community Manager
Jan 31, 2024 7:02 AM UTC

@Taries, Welcome to our community! To help you get the best possible answer, I have tagged in our HBase and Spark experts  @smdas  @RangaReddy who may be able to assist you further.

Please feel free to provide any additional information or details about your query, and we hope that you will find a satisfactory solution to your question.

Translate
Regards, Vidya Sargur Madabhushi| Senior Community Manager | Was your question answered? Make sure to mark the answer as the Best Answer. If you find a reply useful, say thanks by clicking on the thumbs up button.
RangaReddy
Gold ⭐️
Gold ⭐️
Jan 31, 2024 8:34 AM UTC

Hi @Taries 

You need to use the following two parameters to apply filter.

hbase.spark.query.timerange.start

hbase.spark.query.timerange.end

Reference:

https://github.com/apache/hbase-connectors/blob/307607cf7287084b3ce49cdd96d094e2ede9363a/spark/hbase-spark/src/main/scala/org/apache/hadoop/hbase/spark/datasources/HBaseSparkConf.scala#L65

Translate
Taries
TariesAuthor
Silver ⭐️
Jan 31, 2024 1:30 PM UTC

Taries_0-1706710173347.png

 

with the above given options, it is only taking the timerange start and end , not considering the rowkey passed along with it. 

Translate
RangaReddy
Gold ⭐️
Gold ⭐️
Jan 31, 2024 2:57 PM UTC

Hi @Taries 

As I mentioned previously, only the hbase.spark.query.timerange parameter can be used for filtering data during read. The hbase.spark.scan parameter wouldn't be set for this purpose.

To filter the data after reading, you can apply a Spark WHERE or filter clause with your desired conditions.

 

Translate
RangaReddy
Gold ⭐️
Gold ⭐️
Feb 4, 2024 3:46 PM UTC

Hi @Taries 

I hope you are doing good. Do you need any further help on this issue. If above solutions is helped in your case please accept the Solution. It will help for others. 

Translate