Databricks Data Engineer Professional exam dumps

Databricks Data Engineer Professional practice question 266 of 313

Databricks Certified Data Engineer Professional. Professional level, Databricks. Free question with the correct answer and a full explanation.

Databricks Data Engineer Professional Question 266

Select 3

You are working on a Databricks project where a Python module was previously packaged and distributed as a Wheel file. However, due to project requirements, you need to adapt the code to use direct imports with relative paths instead of depending on a Wheel file. Which steps should you take to accomplish this?

  1. A

    Replace absolute imports in the Python code with relative imports using dot notation for modules within the same package.

  2. B

    Remove the setup.py and setup.cfg files that were used to create the Wheel package.

  3. C

    Ensure that all dependent modules in Databricks are installed as libraries instead of relying on relative imports.

  4. D

    Update the Databricks notebook environment to include the root directory of your Python package in the sys.path variable.

  5. E

    Convert all import statements to use absolute imports instead of relative imports, as Databricks does not support relative paths.

Show answer and explanation

Correct answers: A, B, D

Explanation

When adapting Python code from a Wheel package to direct imports, the main steps involve switching to relative imports, cleaning up unnecessary files used for packaging (e.g., setup.py), and ensuring that the Python runtime can properly resolve the package's path. These steps ensure that the code works within the Databricks environment and does not rely on the Wheel distribution format.

  • A. Correct.

    Correct: To adapt Python code for relative imports, you need to use dot notation (e.g., from .module import ClassName) for modules within the same package. This ensures the code works without requiring an installed Wheel package.

  • B. Correct.

    Correct: The setup.py and setup.cfg files are specific to building and distributing Python packages like Wheels. If you are moving to direct imports, these files are no longer necessary.

  • C. Incorrect.

    Incorrect: Using Databricks libraries is unnecessary when switching to relative imports for a package. This step is unrelated to the problem scenario.

  • D. Correct.

    Correct: Adding the root directory of your Python package to sys.path ensures that Python can resolve your package and its modules correctly in the Databricks environment.

  • E. Incorrect.

    Incorrect: Relative imports are supported in Databricks, and using absolute imports is not a requirement. This contradicts the scenario where relative imports are explicitly needed.

Timed practice exam

Take a Databricks Data Engineer Professional practice test under exam conditions

60 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam