Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Read JSON into BigQuery
00:00
5 left

Read JSON into BigQuery

MediumPython

Problem

Write a function that reads a JSON file and loads it into BigQuery.

Asked in the round 1 stage. For deterministic grading, the file contents are supplied as file_content; the function validates a JSON array of objects and returns the number of records that would be loaded.

Input and Output

file_path, project_id, dataset_id, and table_id are strings. file_content is a JSON string whose root must be an array of objects. Return the record count. Raise ValueError for an invalid root.

Constraints

  • All file and destination parameters are strings
  • file_content is valid JSON for valid inputs
  • The JSON root must be an array
  • Every array element must be a JSON object
  • The number of records is between 0 and 10^4

Function Signature

def load_json_to_bigquery(file_path, project_id, dataset_id, table_id, file_content):
Interviewer

Your question is Read JSON into BigQuery. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
Sign up free to run your codeLog inLn 2
Run your code to see test output here.